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

后端 未结 9 2289
萌比男神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:12

    Having two Main methods is just fine. If you receive the error you mentioned then you need only to tell Visual Studio which one you'd like to use.

    1. Right-click on your project to view the properties.
    2. Go to the Application tab and choose the entry point you desire from the Startup object dropdown.

    Here's an example where I have two entry points depending on how I want to dev-test the assembly.

提交回复
热议问题