Tuesday, July 24, 2018

How do you handle the message, Project with an Output Class Library cannot be started directly?

This is a typical message that you get from Visual Studio when you try to debug a project of type Class Library. The project produces a Class.

In order to get around this error, you should create another project, can be in the same Solution which can be executed. In this executable project you should reference the Class Library project. Also, you should designate the executable project as the Start Up Project.

Here is a typical class library project that depends on the .NET Framework.

ClassLibFrame_1.png

This project can be built, but when you try to Start this project without debugging you will get the Visual Studio message.


You can get around this and run provided you add another executable project shown here to the Solution:



OutputTypeCannotbeStarted_1

The Main() program of the project FindJoin is shown here:


OutputTypeCannotbeStarted_2


Also you need to mark FindJoin as the Start up project from Solution Explorer.


OutputTypeCannotbeStarted_3

With this accomplished you can do a Ctrl+F5 to Start without debugging and you should see the response as shown:



No comments: