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 outp开发者_C百科ut 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.
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.
- Do not add an .sln to another solution. Add the Project (.csproj) instead.
- When 2 projects are in the same solution there still is no link by default. Use Add Reference in the importing project.
- Set an executable project as the Startup project.
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.
Rightclick on your references folder, press "add reference", switch to "projects" and add the reference to your library project.
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.
There are already good answers, but I would also suggest creating a Test project as a more efficient way of debugging the library.
精彩评论