Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
383 views
in Technique[技术] by (71.8m points)

c# - "A project with an Output type of Class Library cannot be started directly"

I downloaded a C# project and 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 a .csproj file.

I installed Visual Studio and opened the .sln file present in the main folder. 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 round this hiccup?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...