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

前端 未结 26 1700
时光说笑
时光说笑 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 13:04

    For some others coming here:

    In my case I had copied a .csproj from a sample project which included <EnableDefaultCompileItems>false</EnableDefaultCompileItems> without including the Program.cs file. Fix was to either remove EnableDefaultCompileItems or include Program.cs in the compile explicitly

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

    Looks like a Windows Forms project that is trying to use a startup form but for some reason the project properties is set to startup being Main.

    If you have enabled application framework you may not be able to see that Main is active (this is an invalid configuration).

    0 讨论(0)
  • 2020-12-05 13:06

    Had this problem in VS 2017 caused by:

    static async Task Main(string[] args)

    (Feature 'async main' is not available in C# 7.0. Please use language version 7.1 or greater)

    Adding

    <LangVersion>latest</LangVersion>

    to app.csproj helped.

    0 讨论(0)
  • 2020-12-05 13:08

    I was looking at this issue as well, and in my case the solution was too easy. I added a new empty project to the solution. The newly added project is automatically set as a console application. But since the project added was a 'empty' project, no Program.cs existed in that new project. (As expected)

    All I needed to do was change the output type of the project properties to Class library

    0 讨论(0)
  • hey i got same error and the solution to this error is just write Capital M instead of small m.. eg:- static void Main() I hope it helps..

    0 讨论(0)
  • 2020-12-05 13:10

    When you want to allow paramaters to be specified from the command, they must look like this:

     [STAThread]
     static void Main(params string[] paramaters)
     {
    

    you cannot specify more than one paramater, otherwise this will also cause the error reported above.

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