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
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With