Error message “CS5001 Program does not contain a static 'Main' method suitable for an entry point”

后端 未结 1 1927
傲寒
傲寒 2020-12-01 01:20

Unable to execute the following code error CS5001 Program does not contain a static \'Main\' method suitable for an entry point

What does this error message mean?

1条回答
  •  伪装坚强ぢ
    2020-12-01 01:47

    It means that you don't have a suitable entry point for your application at the moment.

    That code will nearly work with C# 7.1, but you do need to explicitly enable C# 7.1 in your project file:

    7.1
    

    or more generally:

    latest
    

    You also need to rename MainAsync to Main. So for example:

    Program.cs:

    using System.Threading.Tasks;
    
    class Program
    {
        static async Task Main(string[] args)
        {
            await Task.Delay(1000);
        }
    }
    

    ConsoleApp.csproj:

    
      
        Exe
        netcoreapp2.0
        7.1
      
    
    

    ... builds and runs fine.

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