Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A project with output type of class library cannot be started directly - with a startup exe

Firstly I'm completely aware of this message and why it happens normally. It's not that I'm just trying to run a dll (like this question).

I have a project that compiles to a dll but has a startup program specified in the project properties. Most of the time I'm able to right-click on the project and select Debug > Start new instance, and it will run the program and let me debug my dll. However, occasionally I get this message (A project with output type of class library cannot be started directly) as if I haven't got a startup program. The first few times I thought it was just me accidentally clicking on the wrong project but I'm certain this isn't the case given that it's happened so many times and I've been careful to watch it.

When this message appears I'm able to try it again and it always works on the second or third attempt.

A colleague using the same Solution never has this problem :-/

Anyone else had this problem or know how to solve it?

I'm using Visual Studio 2005 Pro Version 8.0.50727.762 (SP.050727-7600) Edit: Also happens with Visual Studio 2010

like image 820
Rory Avatar asked Apr 16 '09 16:04

Rory


People also ask

How do you fix project with an output type of class library Cannot be started directly?

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 I set an EXE project as a StartUp project?

You need to create a project which uses the class library, then set it as the startup project by right-clicking the project name in Solution Explorer and selecting "Set as Startup Project."

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

Solution. Right click on the Solution Explorer of your project in the right top corner of the IDE and the select the Properties option located in the dropdown menu. Now from the Solution Property Pages dialog that appears, select the StartUp Project list option.


2 Answers

Another colleague suggested it's because after clicking Debug > Start new instance, while I'm waiting for it to start up, I click on a different project. I don't do it for any reason, just randomly selecting things as I wait for the project to start up. Maybe Visual Studio looks at the selected project sometime after I clicked the menu, gets confused, and shows the error message?

Anyone able to confirm this matches their experience?

like image 172
Rory Avatar answered Nov 05 '22 19:11

Rory


Typically problems in VS are caused by:

  • Add-ins: Run VS without and see if the problems is solved
  • Corrupted files in your solution: Delete / rename all files created by Visual Studio which are not part of your project, i.e. all .suo, .ncb files and a like.
like image 26
Dirk Vollmar Avatar answered Nov 05 '22 19:11

Dirk Vollmar