views:

112

answers:

3

Guys,

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. ......

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

What should I do to get ahead of this hiccup?

Help!

+1  A: 

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.

AllenG
+2  A: 

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.

James Curran
Hey James, Okay I have added a new project in the same solution. A new .cs file is created which has a main function. Now what should I reference to. To the dll you mean? When I right click on the references tab, I get a Add Reference window.
vikramtheone
Navigate to the Projects Tab. There will be the set of assemblies defined in your solution available for referencing.
Eugene Cheverda
Yes, exactly. Don't forget to add specific usings to have ability of using classes of that library.
Eugene Cheverda
+2  A: 

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

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

In 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.

Eugene Cheverda