[Solution] an error occurs when the xNa game program startup page is changed to the WPF form.

Source: Internet
Author: User

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 ();
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.