开发者

Visual Studio 2008 resolving wrong reference

开发者 https://www.devze.com 2022-12-09 02:03 出处:网络
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\">

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\Microsof开发者_JAVA技巧t.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


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)


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.


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.
0

精彩评论

暂无评论...
验证码 换一张
取 消