“A project with an Output type of Class Library ca

2019-01-02 15:40发布

I'm a novice in C# and Visual C# IDE, I don't know anything about how to use them at all. I have programmed all my life in C on EclipseIDE. I have searched on several places how to solve this problem but could not get a proper procedure to do so. I'm posting the question here, for that reason.

I downloaded a C# project, I wish to debug the project to see how an algorithm implementation works.

The project has come in a Folder, inside this folder there are -

  1. .sln file and
  2. a folder which has - Source files and .csproj file.

I installed Visual Studio C# Express and opened the .sln file present in the main folder in the VS C# IDE. I built the project successfully, but when I try to debug the project I get this message:

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.

The strange part is that I don't see a main function anywhere.

What should I do to get ahead of this hiccup?

12条回答
谁念西风独自凉
2楼-- · 2019-01-02 16:06

You'll need some kind of app (Console Apps are my favorite for debugging, but a WinForm will do) which uses your Class Library. Just add a new project (in the same solution) of a Console Application or Windows Forms Application, and add a reference to your current project. Once you've done that, make any calls you need, set your break points, and go to town.

查看更多
美炸的是我
3楼-- · 2019-01-02 16:07

Error solutions is that you have already open your project but by mistake you have selected another class library .. that's reason this error is showing ... so what u need to do you u just select u r project then right click on u r project

after right click u can see the list box and select the "Set as start up project " option .

Saikat Banik

查看更多
大哥的爱人
4楼-- · 2019-01-02 16:07
    Right Click on "Solution Explorer" -> "Properties"
    Expand "Common Properties"
    Select "Start Up Project"
    click the radio button "Single Start_up Project"
    select your Project name from the drop down list.

If still not working after the above steps, then try this.

    Expand solutions explorer.
    Right click on project name -> "Properties"
    Go to "Application" tab
    Select "Output type" 
 From the drop down list select the appropriate type according to your application.
    "Windows application" or
    "Console application"

Then save (ctrl + S)

Try debugging (F5)

查看更多
呛了眼睛熬了心
5楼-- · 2019-01-02 16:09

The project you have downloaded compiles into a dll assembly and provide a set of classes with implemented functionality.

You should add to your solution a new project with Output Type of either Console Application or Windows Application (VS Add Project wizard will offer you different templates of Projects).

In the newly added project, you can implement logic to test your Class Library.

Output type of the project you can find and change by the following steps:

  1. Right click on project in Solution Explorer -> Properties.

  2. In opened tab with properties select Application and there will be ComboBox marked with Output Type label.

查看更多
孤独总比滥情好
6楼-- · 2019-01-02 16:14

Just needs to go:

Solution Explorer-->Go to Properties --->change(Single Startup project) from.dll to .web

Then try to debug it.

Surely your problem will be solved.

查看更多
春风洒进眼中
7楼-- · 2019-01-02 16:17

The strange part is that I don't see a main function anywhere.

That is exactly your problem. The project merely creates a DLL. It has no executable to run.

You will need to add a second project, which is an executable which references the other project, and calls something in it.

查看更多
登录 后发表回答