
The Problem
Lately I’ve been experiencing some frustrating problems with references to DLL files in a Visual Studio solution. Since I’m working with a team of other programmers, we are obviously using a code versioning system—in this case SourceSafe. It seems that nearly every time I “get the latest version” of the solution from SourceSafe and then try to build it, I will get errors with references to missing DLLs. However, the “missing DLLs” actually exist. The problem is that the references to these DLLs within the solution are wrong.
Because each of the other programmers have a different path to their own copies of the same solution, they also have different paths to the DLLs that are included in that solution. One programmer will notice that his stuff isn’t compiling, he’ll fix the reference error, check it in, and then simultaneously break it on all the other programmers’ machines (Or at least all those will a different file structure).
The Fix
To fix it, you’ll want to use “Reference Paths” within Visual Studio:
- In Solution Explorer, right-click your project node and click Properties. The Project Designer should appear.
- If you are using Visual Basic, select the References page and click the Reference Paths button. In the Reference Paths dialog box, type the path of the folder that contains the DLL that you want to reference in the Folder field, then click the Add Folder button. If you are using C#, select the Reference Paths page. In the Folder field, type the path of the folder that contains the item you want to reference, and then click the Add Folder button.
That’s it! Reference Paths are saved within each user’s own profile, so they will not be propogated to the other SourceSafe users when you check in your files. When you build a solution, Visual Studio will first try to find the DLL with the hardcoded path that is provided within the solution. If it can’t find it, then it will look within the Reference Paths for the file, where you should now have the correct reference to the DLLs.
References:
http://msdn2.microsoft.com/en-us/library/ayds71se(VS.80).aspx