I have two projects with two different solution in Visual Studio 2015. How I can add a reference from first project to second project? thanks
-
Just to be sure - do you have 2 different solutions or a single solution with 2 projects? Since my answer is for the second case.David Ferenczy Rogožan– David Ferenczy Rogožan2016-06-09 18:02:15 +00:00Commented Jun 9, 2016 at 18:02
-
1@OP: Referencing the binary in the debug folder works as a quick hack, but what you should really be doing is using the class library package projects in VS 2015. This builds your projects into nuget packages, which will make things easier for you once you get to publishing.user1726343– user17263432016-06-09 18:06:56 +00:00Commented Jun 9, 2016 at 18:06
4 Answers
The way I see it, if you find yourself having to do this you should ask your self if both solutions tackle on a similar problems then you should consider joining then into one single solution. If on the other hand what you need to use between the 2 solutions is some utility library, then perhaps you should consider making it a NuGet package see documentation or examples.
If you think none of the above is best for you then you should go with:
- Right click on References
- Select Add Reference
- Click on Browse
- Browse to the compiled DLL (debug/release) of the other solution
- Click OK some times
as in the previous answers.
Comments
Follow these steps:
- right-click the References node in the Solution Explorer under the project you want to add the reference into
- for the projects from different solutions:
- build the project you want to add as a reference first
- open the other solution and in the Add Reference... dialog of the project you want to add the reference into click on the Browse... button and navigate to the binary directory of the other project (usually the
bindirectory under the project's root directory) and select yourproject.dll
- for the projects inside the single solution:
- click Add Reference... and select the Solution under the Projects node
- check projects you want to add as a reference
- add the namespace you want to use (
using Namespace.Project) to your source code where you want to use it
Note: to find out the full namespace of the project, open the project's properties (right-click on the project in the Solution Explorer, click Properties..., select the Application tab and check the Default namespace.
Under the Project entry in the Solution Explorer, expand it and look for References towards the top of the children. Right click and choose Add Reference.
In the dialog that opens, on the left side choose Browse and then select the dll from your other project.
Alternatively you can right click the Solution node itself and click Add Existing Project, but that's not quite the same.