zoukankan      html  css  js  c++  java
  • [解决]XNA游戏程序启动页面改为WPF窗体所出现的错误

    我计划将XNA Windows Game4程序 改为从WPF窗体程序启动,出现如下错误:

    WPF error: does not contain a static 'Main' method suitable for an entry point does not contain a static 'Main' method suitable for an entry point


    如果你当前项目中的App.xaml未自动生成,如你新一个Windows Game项目,
    但你想启动窗体用WPF窗体,那么当你从别处拷一个App.xaml或新建一个这样的文件时,则会出现
    这样的情况。

    同样,当你在Visual Studio中删除App.xaml从别的位置拷贝一个后会出现的编译错误。

    出现该问题的原因在于:

    默认的App.xaml在属性页中的Build Action 是ApplicationDefinition,而拷贝过来的文件默认不是这样的。(如我拷贝过来后,该属性为 CodeAnalysisDictionary) 。

    解决方法:

      将App.xaml的Build Action 设置为ApplicationDefinition,

      他才会为我们生成所需的静态Main方法,这样程序才能够正确的被编译。
     


      在"项目根目录\obj\x86\Debug\App.g.i.cs"文件中我们可以找到正确编译后生成的Main函数
       内容如下所示:(以WindowsGame1项目为例)
      /// <summary>
            /// Application Entry Point.
            /// </summary>
            [System.STAThreadAttribute()]
            [System.Diagnostics.DebuggerNonUserCodeAttribute()]
            public static void Main() {
                WindowsGame1.App app = new WindowsGame1.App();
                app.InitializeComponent();
                app.Run();
            }

  • 相关阅读:
    CentOS 5.5 系统安全配置
    从PHP5.2.x迁移到PHP5.3.x
    快要放假了!但为什么现在感到特别的累呢?!
    C#、Oracle、Sql server中拼音查询的函数
    C#实现Word中表格信息读取
    用 win2003 架设共享服务器[3]
    用 win2003 架设共享服务器[2]
    用 win2003 架设共享服务器[1]
    c#操作word表格
    Visual Studio 2008(VS2008)升级正式版
  • 原文地址:https://www.cnblogs.com/furenjun/p/xnawpf.html
Copyright © 2011-2022 走看看