“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 15:51

Just right click on the Project Solution A window pops up. Expand the common Properties. Select Start Up Project

In there on right hand side Select radio button with Single Startup Project Select your Project in there and apply.

That's it. Now save and build your project. Run the project to see the output.

查看更多
情到深处是孤独
3楼-- · 2019-01-02 15:55

You can right click the Class Library project and from the drop-down choose Initialize Interactive C# which will load your project context and you can work it in the interactive session.

查看更多
路过你的时光
4楼-- · 2019-01-02 15:59

Suppose you have multiple project in the solution. Select the project that you want to view in browser and select 'Set as StartUp Project'. In your multiple project soln which was the main, the visual studio was unable to identify. this was the main problem.

查看更多
有味是清欢
5楼-- · 2019-01-02 16:02
1) Right Click on **Solution Explorer**
2) Go to the **Properties** 
3) Expand **Common Properties**
4) Select **Start Up Project**
5) click the radio button (**Single Start_up Project**)
6) select your Project name 
7) Then Debug Your project
查看更多
旧人旧事旧时光
6楼-- · 2019-01-02 16:03

This was the solution that worked for me since I couldn't find 'Common Properties' option.

  1. Select your topmost level project in Solution Explorer.
  2. Go to Project, and in contextual menu Set as StartUp Project.

    Set as StartUp Project

See also: A project with an Output type of Class Library cannot be started directly

查看更多
何处买醉
7楼-- · 2019-01-02 16:04

I had a similar issue when trying to use the Experimental Instance of Visual Studio 2013. This was for a vsix project (Creating Snippets).

Solution was:

Right Click Project in Solution Explorer > Properties > Debug

Setting the Start Action to "Start external program" and using the following path:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe

This option was set to "Start project" which won't work for the application output type Class Library, which caused that same error.

Note: Yours may differ depending on how you installed VS.

查看更多
登录 后发表回答