Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

I've download sample code with C#. but when I run I get this error message:

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.

Please give me a solution.

like image 794
hin leaksmei Avatar asked Jun 22 '12 07:06

hin leaksmei


People also ask

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

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.

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.

Can class library project run in C#?

This tutorial shows, how to build a simple Class Library . DLL in the C# Programming Language. The Class Library . DLL contains program code, data, and resources that can be can used by other programs and are easily implemented into other Visual Studio projects.


2 Answers

The currently selected startup project is a Class Library.

You need an entry point for your application. Does your solution contain multiple projects?

Are you sure you want to 'run' the Class Library?

enter image description here

Possibly you've downloaded a Class Library solution only. In that case there might be unit tests that you can 'debug' to step-trough the code.

Update In response to your comment, these are possibilities to run the class library:

  • Create a console application and reference the class library. Then 'use' its contents
  • Debug an unit-test project
  • start existing client project
like image 80
Myrtle Avatar answered Sep 22 '22 09:09

Myrtle


If you have a project with an executable right-click this and select "Set as start project" - if not you have to write one to debug your code (or use Unit-Tests).

like image 26
Random Dev Avatar answered Sep 20 '22 09:09

Random Dev