Error: A project with an out put type of class library
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 Libra开发者_如何学运维ry 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
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:
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:
- An asp.net web application
- A windows application (WPF or winforms)
- A console application
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.
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.
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)
You selected the wrong project type. You might want an ASP.NET project, WinForms project, WPF project, Silverlight project or console project instead.
精彩评论