hamze torabzade
hamze torabzade

Reputation: 7331

add a c# library project to my project and how to use it

i have c# library project. i add it(library.sln) as a existing project to my project. so it comes to my solution explorer.

but in my forms when i try to access it, it seems it dose not exist using library; is noting ! where am i wrong, and what i need to do ?

it can not be build itself in visual studio when i try to debug project, the error is :

a project with an output type of class library can not be started directly

you can see the library project here http://www.codeproject.com/KB/selection/FarsiLibrary.aspx?msg=4043318#xx4043318xx and it have 4 namespace.

Upvotes: 0

Views: 1663

Answers (6)

rgargente
rgargente

Reputation: 1840

There are already good answers, but I would also suggest creating a Test project as a more efficient way of debugging the library.

Upvotes: 0

Kevin
Kevin

Reputation: 6292

You need to use the "Set as StartUp Project" option in your context menu to set a runnable project. The project "library" you created is probably a class library which is not runnable.

Create some runnable project e.g. Condole application to use your library and set that as startup project. Then run your project.

Upvotes: 2

Henk Holterman
Henk Holterman

Reputation: 273591

  1. Do not add an .sln to another solution. Add the Project (.csproj) instead.
  2. When 2 projects are in the same solution there still is no link by default. Use Add Reference in the importing project.
  3. Set an executable project as the Startup project.

Upvotes: 2

Sascha
Sascha

Reputation: 10347

Even if you add the project to your solution, you have to add a reference to that project for the WinForms project. This has nothing to do with the library.

If your WinForms uses .NET 4 Client Profile and the library requires .NET Full, then you can't access it and need to change the WinForms project to use the full .NET 4 runtime.

Upvotes: 0

Felix C
Felix C

Reputation: 1775

Rightclick on your references folder, press "add reference", switch to "projects" and add the reference to your library project.

Upvotes: 0

Bodrick
Bodrick

Reputation: 342

A library is just a collection of classes, interfaces, enums etc.. In order to debug it, you'll probably want to create a console application that calls methods on your classes that you want to debug.

In addition, just adding the library to the solution is not enough for other libraries to be able to see them. In order to do this, you have to add it as a reference. You can do this by right clicking on the References item in your project, then Add Reference.

Upvotes: 0

Related Questions