Compile-time prompt error when creating App.xaml as Startup Project manually:
1>------started Build: project: WpfApplication11, configuration: Debug any CPU------1>csc:error CS5001: Program "e:\refcode\c#\.....\obj\ Debug\wpfapplication11.exe "does not contain a static" Main "method that is appropriate for the entry point ========== generated: 0 successful, 1 failed, latest 0, skipped 0 ==========
the first idea after seeing this problem is to write the main method in the App.xaml.cs file? It seems that there is no main method in the App.xaml.cs file of the previous WPF project. A new WPF project was re-created, comparing the App.xaml and App.xaml.cs files with the existing ones, with basic key elements. There's no way to see where the project configuration can be configured to start the association.
Viewing all tabs in the Project Properties dialog box, it seems that only the startup object in the Applications tab may be related to the startup point of the program. The Startup object defaults to "not set". Click the drop-down box and no drop-down items were found. You can actually drop-down to see the app files by opening the new WPF project that you created earlier. So guess vs has special handling of app files within the project file.
Compare the project configuration file:
To create a WPF project directly:
<applicationdefinition include= "App.xaml" > <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType></ApplicationDefinition>
To add your own class library to the WPF project:
<page include= "App.xaml" > <Generator>MSBuild:Compile</Generator> <SubType> Designer</subtype></page>
In a directly-created WPF project, App.xaml in the project file.
ApplicationDefinitionThe label definition. In the later class library to WPF project, App.xaml is defined in the project file with the page tag, which means it is just a page. Therefore, you only need to change the configuration of App.xaml to the project file in the class library to WPF project
ApplicationDefinitionTo find the problem solved.
WPF does not contain a static "Main" method that is appropriate for entry points