I added a new class to my project and got an error saying “Program.Main() has more than one entry”. Why?

后端 未结 9 2299
萌比男神i
萌比男神i 2020-12-06 00:19

The problem is that after I added the new class, the error came up when I did build the solution. What can be wrong?

In Form1, I don’t have any code yet.

I jus

9条回答
  •  鱼传尺愫
    2020-12-06 01:06

    When you add a new class in your project and also you write the Main method, and when you run your code at that time it shows the error like "More than one Main method found", then you just need to:

    1. Right click on your project name which is shown in "Solution Explorer" then
    2. go into Application and in the Startup object dropdown menu choose your class which you want to run. If you don't find your class name in it, then simply just restart your IDE and again follow the above steps.

提交回复
热议问题