3

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.

RonYamin
  • 77
  • 2
  • 11
  • Did you re-compile it after restoring from backup? Is the backup valid? Is it included in the project or just a file in the directory? Basically, following the error message, *is there* a `static Main` method in the application? (Side note: An effective way to undo a breaking change in the code is to revert to a known working version from source control.) – David Oct 18 '14 at 15:19

1 Answers1

14

In the file properties, set Build Action to ApplicationDefinition:

file properties

This will generate a Main method for you in the intermediate output files (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();
}
Lucas Trzesniewski
  • 50,214
  • 11
  • 107
  • 158