Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A project with an Output Type of Class Library cannot be started directly.

When I try to run my application, I ge the the following error; enter image description here

I know this issue has come up many times, and the usual answer is to right click on the appropriate project and make it the start up project.

Well I have done that and this does not fix it.

My application is an MVC application, so the start up project should be a class library.

It was working fine until I tried to upgrade it to MVC5.

I am working on VS 2012.

I am wondering if the problem was caused by unloading and reloading the csproj file which I edited as part of the upgrade?

like image 527
arame3333 Avatar asked Jun 27 '14 16:06

arame3333


People also ask

How do you debug a project with output type class library?

A project with an output type of class library cannot be started directly. In order to debug this project, add an executable project to this solution which references the library project. Set the executable project as the startup project.

How do you change the output type of the project properties to the class library?

Right click the project and click "properties", the default Output type is "Console Application", which should be "Class Library". Change the Output value from "Console Application" to "Class Library".

How do I add an executable project to this solution which references the library project and set the executable project as the StartUp project?

Solution 1Open the Solution Explorer pane in Visual Studio, find the EXE project branch and right click it. In the drop down list that appears is "Set as Startup Project". Click that, and the EXE will run when you debug.


2 Answers

I think it might have something to do if there are multiple projects in the solution. I was getting the same problem when I had a MVC project and the testing project in the same solution. What fixed it for me was setting the MVC project as the StartUp project. This is done by right clicking on the MVC project and selecting "Set as StartUp Project".

This works for VS2013 Professional

like image 153
user2337029 Avatar answered Oct 06 '22 05:10

user2337029


I had the same issue and corrected by altering the projecttype guid. Here is an example:

<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
like image 20
user7392049 Avatar answered Oct 06 '22 05:10

user7392049