WPF does not contain a static "Main" method that is appropriate for entry points

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.