I recently ran into an interesting aspect of WPF applications that I had not previously seen. It started with this error:
Program 'DemoCorp.UI.exe' does not contain a static 'Main' method suitable for an entry point
I had copied an App.xaml file from an existing application into a new application I was creating, because I wanted the resource definitions and thought that would be an easy way to do it. I then deleted the App.xaml that was automatically generated in the new application, which created the compiler error above.
As it turns out, there's a special output type for the App.xaml file to make it generate the Main method. Here's an App.xaml in the solution explorer:
If you click on the properties tab to get the file properties for the App.xaml, you'll see something like the following:
To generate a suitable Main method, the Build Action must be set to ApplicationDefinition as shown in this image. As soon as I figured this out, everything worked great.
28 comments: (+add yours?)
Sweet, thanks for the insight Joe. I love your posts the point out the solutions to "odd" problems. It really helps the rest of us find the answer quickly. Keep up the good work man.
Thank you. I was stuck and wondering what is wrong with my build.
-sri
thanx a lot, it was helpful.
Went through the EXACT steps you did and got stuck. Thanks for the help.
Thanks. That was exactly the problem I had.
You and google are my heroes. You for this post, and google for helping me find it.
thank you very much Joe!
Thank you. Someone suggested changing my Build action to page in another article and as a result I started getting this error. This is exactly what I needed to know.
Thanks a lot. I was worried to see that message thinking i have done something terrible :)
Thanks a lot
Exactly what I was looking for- thanks!
Thanks a lot. Your solution is very useful. I was so happy after solving the problem.
Thanks, you just saved my day
I thought I would end up spending an hour googling for an answer, yours was the first hit with exactly what i needed, thanks so much...
I bumped into this problem when I removed my App then added it again - SAME file but now totally screwed because of the property change.
Thanks for the solution!
Thank you very much. You saved me much frustration!
You rock. Saved my time on this stupid issue.
Thanks, you saved my whole day with this post.
Thanks for this, just got the same issue :)
Hi Joe,
Thanks a lot. This information was pretty useful. I wasted 30 mins on this issue before reading the blog, but this blog helped me to solve it in sceonds.
Thanks alot!
Thank you very much
thanks alot :)
Thank You..
Thanks!
Thanks, very helpfull!
Thank u,it was useful
thanks. That did the magic.
Post a Comment