Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I have created a c# project and then added another project to it.the issue is the first project only consists of class libraries.while the second project has a console application where i have called main().I now want to remove the 2nd project and call main() in one of the class libraries. but when i do this every time i get error no valid main.

What I have tried:

tried clickling properties of first project and changing one class library to console under application tab.but issue persists
Posted
Updated 19-May-17 6:17am
Comments
[no name] 19-May-17 11:18am    
" call main() in one of the class libraries" class libraries do not have a "main" function for you to call and even if they did, you don't call the main function at all.
Rick York 19-May-17 12:03pm    
If you look at the "Related Questions" column to the right you will see several similar, if not identical, questions on this topic. Did you look at them? It can save you a lot of time to first look at questions that are similar to yours.

1 solution

In order to be an EXE file, an assembly must contain one (and one only) Main function which is declared as static - if it does not have such, it is not a valid executable, it is a class library and cannot be executed (it should have a .DLL extension instead of .EXE).
You cannot execute DLL files directly: you need to set your EXE file project (the one with the Main method) as the "Startup project" for the solution.
Open the Solution Explorer pane, and right click the project containing the Main method.
From the pop-up menu, select "Set as Startup Project". The project name will be shown as bold.
 
Share this answer
 
v3

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