Reputation: 195
I am trying to figure out .net and got this code that when I try to run from VS 2008 it gives me this error
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 to the library project. Set the executable project as the startup project
I am learning C# so have no idea what to do here
Upvotes: 11
Views: 17926
Reputation: 158319
A class library is, simply put, an assembly that exposes functionality that can be used by other assemblies, but it cannot be executed on its own. It needs some sort of consumer to make sense. This consumer can be one of many things, such as:
If you are not interested in developing a client application but just the class library, you typically use a unit testing framework which can invoke methods in the class library for testing purposes.
Upvotes: 3
Reputation: 13947
You need to have a project that is runnable in order to use this assembly. If you add a project of type "Console Application" or "Windows Forms Application", you can use this assembly as a reference and use your code.
Is there more than one project in your solution? If so, (and if one of them are of a runnable type), you can right-click on one of them and set as startup project to be able to begin debugging.
Upvotes: 2
Reputation: 1038930
You cannot run a library. You could only run an executable or a web site. So right click on the corresponding project and Set as StartUp Project. Then you can run it:
Upvotes: 21
Reputation: 190942
You selected the wrong project type. You might want an ASP.NET project, WinForms project, WPF project, Silverlight project or console project instead.
Upvotes: 1
Reputation: 1923
In your solution explorer right click on your web or forms project and hit set as startup project.
Your trying to launch a class library (which is not possible)
Upvotes: 1