Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

More Than Two main Method in Visual Studio application?

Tags:

In my project I am having more than two Main method with same signature. One is a winForm and other one is Console class.

How to set any one of them as entry point.

I declared [STAThread] before one main method to set entry point but It's not working?

I am using Visual Studio express 2010

like image 390
PawanS Avatar asked Dec 10 '10 05:12

PawanS


People also ask

Can my application have more than one main method in C#?

You can have more than one main method, you can specify which to use as the entry point for the application by your compiler. See this link for more detail. When I have 3 Main functions in different class files, only 2 Main methods available in "Startup object" option in Application property in the project.

How do you call two methods from main method in C#?

Go to Project -> Properties -> Aplication Tab -> Startup object. You will see that both of the Main() method holders (classes) are listed there as shown in the image below. As shown in the previous image, select one of the Main() methods and execute the program.

Where is the main method in Visual Studio?

Go into the project properties by right clicking the project in the solution explorer and click properties. On the first tab you will see a drop down list for the entry point. Select the appropriate main method.

How do you fix program has more than one entry point defined compile with main to specify the type that contains the entry point?

If you have more than one class that has a Main method, you must compile your program with the /main compiler option to specify which Main method to use as the entry point.


1 Answers

Go into the project properties by right clicking the project in the solution explorer and click properties. On the first tab you will see a drop down list for the entry point. Select the appropriate main method.

like image 165
Josh Avatar answered Sep 20 '22 11:09

Josh