. Advertisement .
..3..
. Advertisement .
..4..
Hi everyone, I’m learning about csharp. While working, I try debug C# project. As a result, I get the 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.
What can I do about the “a project with an output type of class library cannot be started directly” issue? Is there a better approach?
The cause:
The project which you downloaded compiles into a dll assembly and includes a set of classes that have been implemented. The project only consists the creation of a DLL. It does not have an executable to run.
Solution:
To solve this error, you have to add a new project with the Output Type of Console Application or Windows Application (You will receive different templates of Projects which are provided by VS Add Project wizard).
You can use logic to test your Class Library in the recently added project.
The following procedures will help you find and alter the project’s output type:
1. In Solution Explorer, right-click on the project and select Properties.
2. Select Application from the properties tab in the opened tab, and a ComboBox with the Output Type label will appear.
Right-click on the Project Solution A window. Expand the common properties. Select Start Up Project
On the right side, select radio button for Single Startup Project. Select your Project and then apply.
That’s it. Save your project and then build it. To see the output, run the project.