Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Experts,

I have a solution named "SampleApp" with a project in it. Then added another project named "MDISample" to it from different directory.

Then re-build the solution with 0 errors/warnings. But when i try to make use of one of the class defined in the "MDISample" project. It throws fatal error.

I want to add an existing project in a different folder to the solution and make use of few classes defined in the second project (MDISample).

Could you just help me out in solving this.

Thanks & regards,

SKS.
Posted

Once you add the project, use the Add Reference dialog on the original project to add a project-reference to this newly added project.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 21-Feb-11 14:28pm    
My 5, but there are different ways of references with important implications about version and strong name, please see my answer.
--SA
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 21-Feb-11 14:28pm    
My 5, but there are different ways of references with important implications about version and strong name, please see my answer.
--SA
You have two different ways of adding references to your existing project.

First of all, from the .NET and run-time standpoint the Assembly always reference Assembly, not a project (projects do not exist during run-time).

When you use Visual Studio and solution, you have two ways to add a reference. First way is to add the reference to Assembly by its main module file (usually, DLL). To do this, you need the Assembly being referenced to be compiled by that time. In Solution Explorer, you select referencing project's References node => context menu => Add Reference => Add Reference dialog => the tab "Browse"; find and select the DLL. This method is mostly used when you don't have source code. Important: you may need to adjust Project Dependencies. Is you do it just for Debug configuration, it will later work on other configurations during build as well.

The other way is Add Reference => Add Reference dialog => Projects. This method is better but needs source code; and both project need to be in one solution. This method will set up project dependencies automatically. The major difference is versions. In this method, the reference prescribed in the project file does not contain version information and strong name (assuming the version and signing is controlled by the referenced project from the same solution and always valid).

In first method, versions and signature (strong name) is a problem. When you change a version of a referenced assembly, the reference becomes invalid; you need to remove it and add again. Come to think about, this is very important feature: it prevents messing up version which could otherwise create run-time crashes.

Finally, there is yes another aspect: all referenced assemblies are copied to the referencing assembly location, that created some mess. The reason Visual Studio does this is to make projects working immediately despite of different directories. I recommend to modify output pass of each project to output all project in the same directory (using relative path like "\..\..\bin.Debug", separately for each configuration (Debug and Release, usually).

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900