wpf 程序不包含适合入口点的静态“main”方法
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26441289/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
program doesn't contain a static 'main' method suitable for an entry point
提问by RonYamin
I know that have a lot of question about this issue but my problem is worst. I have a big project that contains a lot WPF application. In mistake I have been deleted the App.xaml, and now I have error in the building.What I try is to take the backup App.xaml and even when I put it again in my project, and I still got this error. What to do ? Thanks.
我知道有很多关于这个问题的问题,但我的问题是最糟糕的。我有一个包含很多 WPF 应用程序的大项目。我错误地删除了App.xaml,现在我在构建中出错了。我尝试采取备份App.xaml,即使我再次将其放入我的项目中,我仍然出现此错误。该怎么办 ?谢谢。
回答by Lucas Trzesniewski
In the file properties, set Build Actionto ApplicationDefinition:
在文件属性中,将Build Action设置为ApplicationDefinition:


This will generate a Mainmethod for you in the intermediate output files (obj/App.g.cs):
这将Main在中间输出文件 (obj/App.g.cs) 中为您生成一个方法:
/// <summary>
/// Application Entry Point.
/// </summary>
[System.STAThreadAttribute()]
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "4.0.0.0")]
public static void Main() {
YourAppName.App app = new YourAppName.App();
app.InitializeComponent();
app.Run();
}

