Question

I have a solution with three projects in it. One is the business layer which has an output set to class library. The second is a UI layer which is currently setup as a console application and the third is a unit test project.

I have referenced the business layer application in my UI and set the startup object to UI.Program but when I try to run the application I get the following 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 the library project. Set the executable project as the startup project.

I cant find the source of this error, and I've tried what others have done to fix this problem with no luck. Any suggestions?

Was it helpful?

Solution

Right click the project you would like as your 'startup project' and select 'Set as start up project'. That should probably solve your problem.

It seems that you're setting the startup object but you have to select a project in your solution as the start up project, this has to be a console application or windows form application.

For more information see the screenshot at this link:

http://www.jeff.wilcox.name/wp-content/uploads/2009/11/VisualStudioSetAsStartupProject.png

OTHER TIPS

I would check the properties on your UI project and make sure the Output Type isn't set to "Class Library" - it should be "Console Application". You may also need to change the Startup Object, but more important make sure the UI has a class that defines this method:

class UI
{
    static void Main() 
    {
    }
}

I suggest the above, but it doesn't sound like missing the Main entry point is your issue, it sounds like the UI project is set to a Class Libary.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top