Class Library - beginner question

onez

Newcomer
Joined
Mar 10, 2006
Messages
10
I get stuck with this Error message when I try to run sample projects. There is a "static void Main method".

Dialog Box message whe try to run:

A project with an Output Type of Class Library cannot be started directly. In order to debug this project, add add an executable project to this solution which references the library project. Set the executable project as the startup project
 
The error message is pretty descriptive of the problem, but I'll try to clarify. The problem is occuring because the sample projects you are attempting to run are dll files (class libraries) as opposed to actual exe's (executables). Class libraries are designed to store additional code segments rather than an entire application. These class libraries can then be imported in to an application, and the code segments can be called.

If you believe the sample projects you are trying to run aren't class libraries you can right click on the project file in the solution explorer and change the Output type from Class Library to either Windows Application or Console Application. It is worth noting however that this will only work if the projcet was not originally intended to be a class file.

If you believe the project is intended to be a class library you can create a new windows application with visual studio (adding it to the same solution file), then right click that project in the solution explorer, select add reference, then add the other project using the projects tab. All of the code from the class file will then be accessible, allowing you to either create included objects or call static methods.
 
Back
Top