I have a WPF project targeting .NET 5 and built with Visual Studio 2019. I declared a custom Main() entry point, and have set the project "Startup object" property to target it. To ensure a Main is not auto-generated, I removed App.xaml/.cs from the project, and re-added it as a Page component, as many have recommended. I can step through the code and see that the correct Main() is being called.
However, after I added a constructor parameter to the App class I get a compiler error in App.g.cs:
CS7036: There is no argument given that corresponds to the required formal parameter...
because it uses the default constructor. Of course it will fail, but why is it still generating a Main() in the first place, and how do I prevent it?
Try to declare an empty constructor as private like this :
And declare your desired constructor as public :