Click here to Skip to main content
13,513,652 members
Rate this:
Please Sign up or sign in to vote.
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 19-May-17 5:10am
Updated 19-May-17 6:17am
NotPolitcallyCorrect 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

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.180417.1 | Last Updated 19 May 2017
Copyright © CodeProject, 1999-2018
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100