[c#] A project with an Output Type of Class Library cannot be started directly

Please can someone could explain why I get this error and what to do to fix it (or what I'm doing wrong!). The steps I have taken are

  1. Download Source code from http://www.codeproject.com/Articles/16859/AForge-NET-open-source-framework
  2. Opening in VS2010 shows the references cannot be found enter image description here

  3. Re-Add all 3 references from PlayingCardRecognition\bin\Release so no further warnings enter image description here

  4. When I try and build or Run I get the following message enter image description here

This question is related to c#

The answer is


Suppose you have multiple project in the solution. Select the project that you want to view in browser and select 'Set as StartUp Project'. In your multiple project soln which was the main, the visual studio was unable to identify. this was the main problem.


If you got this issue (got it in Visual Studio 2017 RC), and you don't get any of the things listed by Mak post from step 3 onward "4 In the Output Type drop box....", it is because you made a Class Library app when you want to create a cross platform app, so here is the solution :

1 Start a new project

2 select Visual C# and cross-platform app.

3 select cross-platform app (Xamarin and native app)

4 select blank form.

From then , right click, select as startup project and build as mentioned by Mak, and it should work.

If you can afford to start from scratch, it could do the trick as it did for me.

This could do the trick for the main issue as well, but must be adapted to your current version of Visual Studio ("Xamarin.forms portable" for visual studio 2015 for example).

Bye!


The project you have downloaded compiles into a dll assembly and provide a set of classes with implemented functionality.

You should add to your solution a new project with Output Type of either Console Application or Windows Application (VS Add Project wizard will offer you different templates of Projects).

In the newly added project, you can implement logic to test your Class Library.

Output type of the project you can find and change by the following steps:

  1. Right click on project in Solution Explorer -> Properties.

  2. In opened tab with properties select Application and there will be ComboBox marked with Output Type label.


Just right click on the Project Solution A window pops up. Expand the common Properties. Select Start Up Project

In there on right hand side Select radio button with Single Startup Project Select your Project in there and apply.

That's it. Now save and build your project. Run the project to see the output.


Error solutions is that you have already open your project but by mistake you have selected another class library .. that's reason this error is showing ... so what u need to do you u just select u r project then right click on u r project

after right click u can see the list box and select the "Set as start up project " option .

Saikat Banik


Your project type is a class library one would suspect, add a ConsoleApplication or WindowsApplication and use that as your startup object. Reference this project and then access the code.


.Exe's and .dll's are both assemblies. The key difference is that executeables define an entry point Main which can be invoked by the runtime. The error

"Class library cannot be started directly"

is due to the fact that said .dll's do not have a Main. To fix this issue, change the project type to a Windows application/Console application and define an entry point. Or, add a new project that is of type Windows application/Console application and reference said .dll.


1) Right Click on **Solution Explorer**
2) Go to the **Properties** 
3) Expand **Common Properties**
4) Select **Start Up Project**
5) click the radio button (**Single Start_up Project**)
6) select your Project name 
7) Then Debug Your project

Just needs to go:

Solution Explorer-->Go to Properties --->change(Single Startup project) from.dll to .web

Then try to debug it.

Surely your problem will be solved.


To fix this issue, do these steps:

Right click the Project name in Solution Explorer of Visual Studio Select Set as StartUp Project from the menu Re-run your project It should work!


Goto the Solution properties -> on Build right side you see the startup project type. here you need to select the console appication/windows appication.


The project is a class library. It cannot be run or debugged without an executable project (F5 doesn't work!!!). You can only build the project (Ctrl+Shift+B).

If you want to debug the code add a console application project (set it as the start up project) to the solution and add the reference to the library.


I had a similar issue when trying to use the Experimental Instance of Visual Studio 2013. This was for a vsix project (Creating Snippets).

Solution was:

Right Click Project in Solution Explorer > Properties > Debug

Setting the Start Action to "Start external program" and using the following path:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe

This option was set to "Start project" which won't work for the application output type Class Library, which caused that same error.

Note: Yours may differ depending on how you installed VS.


    Right Click on "Solution Explorer" -> "Properties"
    Expand "Common Properties"
    Select "Start Up Project"
    click the radio button "Single Start_up Project"
    select your Project name from the drop down list.

If still not working after the above steps, then try this.

    Expand solutions explorer.
    Right click on project name -> "Properties"
    Go to "Application" tab
    Select "Output type" 
 From the drop down list select the appropriate type according to your application.
    "Windows application" or
    "Console application"

Then save (ctrl + S)

Try debugging (F5)


Set your api project to a startup project: Right click the api Project than choose Set as startup Project.


You can right click the Class Library project and from the drop-down choose Initialize Interactive C# which will load your project context and you can work it in the interactive session.


The strange part is that I don't see a main function anywhere.

That is exactly your problem. The project merely creates a DLL. It has no executable to run.

You will need to add a second project, which is an executable which references the other project, and calls something in it.


The project you downloaded is a class library. Which can't be started.

Add a new project which can be started (console app, win forms, what ever you want) and add a reference to the class library project to be able to "play with it".

And set this new project as "Startup project"


The project you've downloaded is a class library, not an executable assembly. This means you need to import that library into your own project instead of trying to run it directly.


To fix this issue, do these steps:

  1. Right click the Project name in Solution Explorer of Visual Studio
  2. Select Set as StartUp Project from the menu
  3. Re-run your project It should work!

If it did not work, be sure that you have set your start page. If your project is C# Windows Application or C# Console Application, try this:

  1. Right click the Project name in Solution Explorer of Visual Studio
  2. Select Properties
  3. Select the Application tab
  4. In the Output Type drop box
  5. Select the correct application type of your project
  6. Re-run your project and let me know if it won’t work.

Just right click on the Project Solution A window pops up. Expand the common Properties. Select Start Up Project

In there on right hand side Select radio button with Single Startup Project Select your Project in there and apply.

That's it. Now save and build your project. Run the project to see the output.

_Sarath@F1


This was the solution that worked for me since I couldn't find 'Common Properties' option.

  1. Select your topmost level project in Solution Explorer.
  2. Go to Project, and in contextual menu Set as StartUp Project.

    Set as StartUp Project

See also: A project with an Output type of Class Library cannot be started directly


VS -> Debug -> Attach unity debugger -> double click project


If you convert the WPF application to Class library for get the projects .dll file.After that convert the same project to the WPF application you get the following error.

Error:".exe does not contain a static main method suitable for an entry point".

Steps to troubleshoot: 1.Include the App.xaml file in the respective project. 2.Right Click on App.xaml file change the build action to Application Definition 3.Now Build your project


You'll need some kind of app (Console Apps are my favorite for debugging, but a WinForm will do) which uses your Class Library. Just add a new project (in the same solution) of a Console Application or Windows Forms Application, and add a reference to your current project. Once you've done that, make any calls you need, set your break points, and go to town.