“does not contain a static 'main' method suitable for an entry point”

后端 未结 7 1285
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-03 15:21

I can\'t figure what\'s my wrong with my code below.

When I try to compile I get the message:

does not contain a static \'main\' method suitab

相关标签:
7条回答
  • 2020-12-03 15:36

    Might be you deleted Program file from your project. Just add Program.cs file your problem get resolved

    0 讨论(0)
  • 2020-12-03 15:38

    Your project must be created as an empty project. So the output type shows as Console Application. Change it to Class library, and it should work

    0 讨论(0)
  • 2020-12-03 15:39

    I just had this issue myself.

    I created a winforms project, decided to refactor my code and the project would now not contain the UI, so I deleted the Program.cs and winforms files only to get the same error you were getting.

    You either need to re add the static void main() method as Matt Houser mentioned above, or go into the project properties and change the output type in the Application tab to Class Library.

    0 讨论(0)
  • 2020-12-03 15:40

    simple change in code. main method should be 'Main' (Capital M).

    0 讨论(0)
  • 2020-12-03 15:41

    Late, but for me, it was a "Console Application" project type, but "Build Action" in the file properties was some set to "None". Changed it to "Compile" and it was fine.

    0 讨论(0)
  • 2020-12-03 15:43

    I have also experienced this wrong. I changed the dropdown situated in Project properties/Application tab (Output type:). The original selected value was "Class Library" but i changed to "Windows Application" and found same error. Now resolved.

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