views:

171

answers:

3

In my project file, I have the following entry:

<Reference Include="Microsoft.Practices.Unity, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <HintPath>..\..\..\..\Libraries\Microsoft.Practices.Unity.dll</HintPath>
</Reference>

which in absolute terms translates to:

C:\dev\LUT600 2.1.1\OCC600\Libraries

Somehow, when I try to compile the project, Visual Studio loads a reference from a totally different path:

/reference:"C:\Program Files\Microsoft Enterprise Library 4.1 - October 2008\Bin\Microsoft.Practices.Unity.dll.

How it resolves to this location is a complete mystery as this DLL is not referenced anywhere in this project.

I have set Specific Verion to true but it still resolves the reference from this location.

Any ideas?

TIA.

Klaus

A: 

It may be that the reference does not have the same version number as the assembly in that particular location, so it starts searching elsewhere to find a "better" match.

Rather than just taking the file you specified, VS always uses a probe path to try to find referenced assemblies. This often provides a random "pick anything with the same name" effect. On our build server I once found 996 copies of an assembly. 995 were the same, correct version, and one was the wrong version. And one day our build stopped working when for no apparent reason it suddenly decided to use the single wrong copy!

Try deleting and recreating the reference. That often helps.

In the worst case scenario, delete all copies of that assembly from your PC, except the version you wish to link to. (if possible without destorying anything you hold dear)

Jason Williams
A: 

You most likely added the reference from the GAC(Global Assembly Cache). The long list of references that take a while to load are references from the GAC. Try removing your reference, and re-adding it by browsing to that assembly in the Add References dialog.

jmaresca
These assemblies are not in the GAC. I added them by browsing to the specific folder but someone VS ignored this.
e28Makaveli
A: 

It could be finding the dll in the Search Path before it evaluates the HintPath. As mentioned in this post, there are two places that are searched before HintPath.

  • Files from the current project – indicated by {CandidateAssemblyFiles}.
  • $(ReferencePath) property that comes from .user/targets file.
ajs410