程序不包含静态的主要'适合入口点的方法

时间:2014-10-18 15:17:56

标签: c# wpf xaml

我知道对这个问题有很多疑问,但我的问题最严重。 我有一个包含很多WPF应用程序的大项目。错误的是我已经删除了App.xaml,现在我在构建中有错误。我尝试的是采取备份App.xaml,甚至当我再次将它放在我的项目中时,我仍然遇到此错误。 该怎么办 ?感谢。

1 个答案:

答案 0 :(得分:13)

在文件属性中,将 Build Action 设置为ApplicationDefinition

file properties

这将在中间输出文件(obj / App.g.cs)中为您生成Main方法:

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