ahmadsfff
ahmadsfff

Reputation: 51

Reference a class in another namespace in another project

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

Upvotes: 2

Views: 3336

Answers (4)

Camilo Terevinto
Camilo Terevinto

Reputation: 32068

Easy steps. Under your project:

  • 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

Upvotes: 3

David Ferenczy Rogožan
David Ferenczy Rogožan

Reputation: 25411

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 bin directory under the project's root directory) and select your project.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.

Upvotes: 1

Luiso
Luiso

Reputation: 4113

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.

Upvotes: 1

jleach
jleach

Reputation: 7790

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.

Upvotes: 0

Related Questions