Click here to Skip to main content
15,893,594 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
When i use multimain in c# it returns following error in compile time.


error CS2001: Source file 'Multimain.cs/main:ClassA' could not be found
fatal error CS2008: No inputs specified

and this is my code

using System;
class ClassA
{
     public static void Main()
     {
        Console.WriteLine(Class A);
     }
}
class ClassB
{
     public static void Main()
     {
        Console.WriteLine(Class B);
     }
}



[Edit]Code is wrapped in "pre" tags[/Edit]
Posted
Updated 7-Jan-11 0:48am
v3
Comments
Venkatesh Mookkan 6-Jan-11 7:02am    
Post you Multimain.cs code.
Hiren solanki 6-Jan-11 7:07am    
can you please show us how you're defining multimain.
#realJSOP 6-Jan-11 7:35am    
See my response to your earlier question about multiple main methdos.

The link with the sample is not quite correct, the /main string is a compiler option and needs to be separated from the program file name thus:
csc /main:ClassA Multimain.cs

// or

csc Multimain.cs /main:ClassA


See also here[^] for more information.

[edit]Added MSDN link[/edit]
 
Share this answer
 
v2
I've found only this:

http://www.dotnetspider.com/resources/22284-Multiple-Main-Methods-C.aspx[^]. (Warning! Don't use as is!)


Even though this is a valid code, it will not compile with default project properties. So, this contribution is practically gibberish, because if does not explain anything.


But I will explain. You can right the code like that, but you also need to go to Solution Explorer -> [your project] -> [context menu] -> Application Tab -> Start up object -> from this combo box, select a class with static method you want to use as an entry point.

Still, your idea in unclear. Did you hope to compile the same application with more then one entry point at the same time and decide which one to run later? This is impossible, period. More importantly, this is a bad idea. I credit here opinion of John Simmons / outlaw programmer. Please see again his answer to your first question. I completely agree with him.
 
Share this answer
 
v6
There[^] is same question in CP forum with solutions.
 
Share this answer
 
STAThread is tells that your program entry point..

C#
[STAThread]
static void Main()
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 6-Jan-11 13:36pm    
Rajesh, Sorry, this is completely wrong. This attribute said what is the Thread Apartment state to set. What's the entry point is defined in the project file. With all my respect -- shame on you. Nobody should give an advice based on a guess. At list you could have said "if I'm not mistaken"...

That's why somebody voted "2".
jerrykid 7-Jan-11 5:26am    
:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900