views:

539

answers:

4

I am using some 3rd party libraries in my solution and have saved these in a separate source-controlled folder called 3rdParty. I have added references to the DLLs in this folder from the VS2008 IDE. However, I find that after saving, closing and opening the solution, the references have been changed to point to the assemblies in the GAC.

The reason for using the 3rdParty folder is that I can easily get latest version from any machine and build my project without having to install anything in the GAC folder. How can I get VS2008 to leave my references untouched?

Edit: After seeing Benjol's answer, I have been wondering if I could use an assembly manifest to fix this. Will this help solve my problem?

A: 

We use a similar approach here where I work, although we call the folder ReferencedDLLs, and we didn't have any problems with it so far.

One thing you can try, though, is to edit the project file to remove the PathHint for the references in question, this way the VS2008 doesn't know where to look and it will start the normal approach.

Paulo Santos
Paulo, how do remove the PathHint? I couldn't locate this in the UI.
Vulcan Eager
I't not on the UI. You need to unload the project and edit the project file manually.
Paulo Santos
I just checked and there were no HintPath or PathHint attributes in the project file. I guess it's different for C++/CLI projects.
Vulcan Eager
Also, I believe that what I'm trying to do works only if the assemblies in question are not already in the GAC.
Vulcan Eager
A: 

There's a "CopyLocal" setting for references, if you set this to true and set the SpecificVersion setting to false then it should use the local references rather than the GAC ones.

GAC dlls are referenced before local ones because they are designed to be shared, but should only be selected if there is a specific version specified.

Would it be possible for you to remove these assemblies from the GAC if they continue to cause problems?

Matthew Steeples
mat1t, my assemblies are in a folder located at ..\..\3rdParty so I don't think CopyLocal will be able to figure out the folder name automatically.The DLLs in questions are available in the GAC for some of the developers since they are using applications which need the GAC references. Deleting the GAC assemblies works but causes problems for folks who need the GAC reference as well.
Vulcan Eager
A: 

Even if you could get VS to look in your local folder, that would be no help at runtime (I mean F5/debug runtime), because .Net will look in the GAC first anyway.

And with reference to CopyLocal, AFAIK, that just tells the compiler to copy a version of your referenced DLL into the /bin folder of your project, so there shouldn't be any issues with 'complicated' paths.

Benjol
Is there any way to force the framework to look in the same directory as the application? Can't manifest files be used to do this?
Vulcan Eager
Short answer, sorry I don't know. Long answer: try looking through this lot: http://stackoverflow.com/search?q=gac+force+local
Benjol
A: 

In order for it to pick up your local assembly you have to go into the project properties, under the Reference Paths tab and add the local directory (3rd party in your case) to the list of directories. This should address your problem.

Mike Brown