问题
I know that this question has been asked a lot, but none of the solutions seem to work for me. That or I am just incompetent and need to have my hand held through this problem (most likely solution). I looked through all of the classes, and all the build actions are set to compile, so I have no idea what could have gone wrong. Any help?
Additional Details: I have been coding the starting of a game, and everything was going good until I got this error:
Program does not contain a static 'Main' method suitable for an entry point
All progress on this project has halted since this error appeared, and I could not find a way to fix it anywhere.
回答1:
I started getting this error on a WPF4/VS2010/MVVMLight app. All suggestions came up fruitless, until I came to the one about creating a new app and comparing the project and XAML files. This sounded like a desperate stab in the dark, but I went ahead and tried it.
After looking at several other files (thank heaven for BeyondCompare!), I discovered that my App.xaml had acquired an extra resource dictionary:
<Application.Resources>
<!--Global View Model Locator-->
<vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" />
<ResourceDictionary>
<vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" />
<ResourceDictionary.MergedDictionaries></ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
Removing the ResourceDictionary block fixed the problem. I still have no idea how this occurred (I wasn't editing app.xaml when this started), and it's not clear why VS reported this as the "static 'Main' method" error. Very strange.
回答2:
Just faced the same problem and following solution solve my problem: If you are using multilayer projects, Right click on the project throwing error and go to properties go to Application Tab and set output type to Class Library and then problem will be solved.
回答3:
Had this same problem. Solution: Be sure the app.xaml properties "Build Action" is set to ApplicationDefinition
回答4:
Try this answer here, it's close to what you have, and few things mentioned,
Program does not contain a static 'Main' method suitable for an entry point
In short you got something 'out of sync' regarding your WPF setup, App.xaml or maybe MainWindow etc. or how you build the project etc.
(note: the main entry point should be auto-generated
, that's the temp file I talked about in the comments - if all is ok, if something's is changed etc. then it doesn't generate and it fails)
Go thru all and make sure - or build an empty WPF project, try with that then compare what's different, minimize the differences, narrow down.
hope this helps
回答5:
Faced the same problem. But in my case I had to create a WPFApplication
but was creating a class library. And upon building the same was getting this error. Try creating a WPF application. Hope it helps.
来源:https://stackoverflow.com/questions/10067063/program-does-not-contain-a-static-main-method-suitable-for-entry-point