WPF not compiling: program does not contain a static ‘Main’ method

I decided to create a new WPF application. I started the project out intending to use WinForms, but then I hit a limitation(pain) that prompted me to switch to WPF. A list of link buttons, easily accomplished in WPF, but annoying in WinForms.

So, I created an App.xaml, deleted my Programs.cs and Main and went compile.

Boom! Error, no Main method. hmmmm… I stared at another one of my WPF projects and didn’t see the magic missing setting. Finally, it dawned on. The compile options for the App.xaml.

Set the compile option to Application Definition and away you go. So simple, yet so non-obvious.


Happy Coding!

0 thoughts on “WPF not compiling: program does not contain a static ‘Main’ method”

  1. Thanks mate. I was pulling my hair out for a short while there trying to figure out why my solution just died on me with the same error. Somehow this setting was changed to just ‘Page’.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.