Troubleshooting “program does not contain a static 'Main' method” when it clearly does…?

后端 未结 14 1820
Happy的楠姐
Happy的楠姐 2020-11-30 08:39

My MS Visual C# program was compiling and running just fine. I close MS Visual C# to go off and do other things in life.

I reopen it and (before doing anything else)

14条回答
  •  天涯浪人
    2020-11-30 09:05

    In my case (where none of the proposed solutions fit), the problem was I used async/await where the signature for main method looked this way:

    static async void Main(string[] args)
    

    I simply removed async so the main method looked this way:

    static void Main(string[] args)
    

    I also removed all instances of await and used .Result for async calls, so my console application could compile happily.

提交回复
热议问题