I plan to add xNa windows game4ProgramStart the WPF form program with the following error:
WPF error: does not contain a static 'main' method suitable for an entry point
If app. XAML in your current project is not automatically generated, such as your new windows game project,
However, if you want to start the form using the WPF form, when you copy an app. XAML from another place or create a file like this
This is the case.
Similarly, a compilation error occurs when you delete app. XAML from Visual Studio and copy one from another location.
The cause of this problem is:
The default build action of APP. XAML on the property page is applicationdefinition, but this is not the case for copied files by default. (For example, after I copy it, this attribute is codeanalysisdictionary ).
Solution:
Set the build action of APP. XAML to applicationdefinition,
This will generate the required static main method for us so that the program can be correctly compiled.
in the "project root directory \ OBJ \ x86 \ debug \ app. g. i. in the CS file, we can find the main function generated after correct compilation.
the content is as follows: (The windowsgame1 project is used as an example)
///
// application entry point.
//
[system. stathreadattribute ()]
[system. diagnostics. debuggernonusercodeattribute ()]
Public static void main () {
windowsgame1.app APP = new windowsgame1.app ();
app. initializecomponent ();
app. run ();
}