Does not contain a static 'main' method suitable for an entry point

前端 未结 26 1697
时光说笑
时光说笑 2020-12-05 12:55

I began organizing my code to day into seperarate .cs files, and in order to allow the methods that work with the UI to continue to do so I would create the .cs code under t

相关标签:
26条回答
  • 2020-12-05 12:56

    I am using Visual Studio and also had this problem. It took me some time, but in my program it was caused because I accidentally deleted a Class named "Program" that is generated automatically.

    0 讨论(0)
  • 2020-12-05 12:59

    I had this error and solved it using this solution.

    1. Right click on the project
    2. Select "Properties"
    3. Set "Output Type" to "Class Library".
    0 讨论(0)
  • 2020-12-05 12:59

    I too have faced this problem. Then I realized that I was choosing Console Application(Package) rather than Console Application.

    0 讨论(0)
  • 2020-12-05 13:01
    1. Select App.xaml and display its properties. Set Build Action to ApplicationDefinition.
    2. App.xaml and its corresponding *.cs file must be placed into the root directory of the *.csproj file, i. e. not into a "Source" folder.
    0 讨论(0)
  • 2020-12-05 13:03

    Try adding this method to a class and see if you still get the error:

    [STAThread]
    static void Main()
    {
    }
    
    0 讨论(0)
  • 2020-12-05 13:03

    After placing the above code in Program.cs, follow these steps:

    1. Right click on the project

    2. Select "Properties"

    3. Set "Output Type" to "Windows Application"

    4. Startup object : namepace.Program

    0 讨论(0)
提交回复
热议问题