Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix WPF error: "Program does not contain a static 'Main' method suitable for an entry point"?

Tags:

c#

wpf

People also ask

What is main method in C#?

The Main method is the entry point of a C# application. (Libraries and services do not require a Main method as an entry point.) When the application is started, the Main method is the first method that is invoked. There can only be one entry point in a C# program.


Check the properties of App.xaml. Is the Build Action still ApplicationDefinition?


Maybe the "Output type" in properties->Application of the project must be a "Class Library" instead of console or windows application.


Just in case anyone is having the same problem... I was getting this error, and it turned out to be my <Application.Resources> in my App.xaml file. I had a resource outside my resource dictionary tags, and that caused this error.


In my case (after renaming application namespace manually) I had to reselect the Startup object in Project properties.


You can also run into this if you're working on a WPF project that was started in VS 2010 (Beta 1), then moved into VS 2008.

Under the project properties, the .NET framework version gets unset (since .NET 4.0 isn't valid in VS 2008), and for some reason that causes this error.

If you set the .NET framework (e.g. to .NET 3.5), the error goes away.