3

I created a class library (I checked to make sure it was set to that in the Application tab of the properties window.) However i am now getting a

Program does not contain a static ‘Main’ method suitable for an entry point

I added a program.cs and added an empty Main method, to no avail. There are about 10 .cs files that comprise this lib. Is that the issue?

rigamonk
  • 1,179
  • 2
  • 17
  • 45
  • 1
    Yes, you cannot run (press F5 in Visual Studio) a class library, you can only build it (press F6 in Visual Studio) – Ian Mar 11 '16 at 15:09
  • 2
    Are you *certain* that a) it's a class library and b) the error is to do with *that* project rather than a different one? Screenshot? (It's rare for me to ask for an image, but...) – Jon Skeet Mar 11 '16 at 15:11
  • 1
    I am just trying to build it (F6) – rigamonk Mar 11 '16 at 15:11
  • 1
    @rigamonk if you are just trying to build it, then it should not have an issue. Your case is quite strange... unless there is something missing here. Building a library should not cause the compiler to ask for entry point (Main). Please check the `Properties` of *that* project and make sure that it has output type of `Class Library` – Ian Mar 11 '16 at 15:13
  • Not sure why you got downvoted. Anyways, in case anyone comes across this post while trying to resolve the issue, here is a (the?) solution: http://stackoverflow.com/questions/41156691/asp-net-core-program-does-not-contain-a-static-main-method-suitable-for-an-en – James Wilson Feb 24 '17 at 22:34

1 Answers1

0

The meaning of a class library is to provide classes that can be shared to other projects. It is not intended to be run as a standalone program. If you want to be able to run an application, I would advise you to create a Console Application, or if you want it to have a UI, to create a WPF or Windows Forms application.

Peter Keuter
  • 778
  • 5
  • 14