在Visual Studio 2010中引用替代引用程序集?

时间:2012-01-26 14:17:26

标签: .net visual-studio visual-studio-2010

我正在尝试使用替代核心框架库,同时仍然以.NET Framework 4.0为目标。当我向备用文件添加手动引用时,Visual Studio会在C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\中创建对同一命名文件的引用。

我可以禁用此行为吗?

2 个答案:

答案 0 :(得分:3)

如果dll已经在GAC中,则删除现有的dll将不起作用 尝试将引用标记为Specific Version = true(右键单击 - >属性)。

编辑:
添加引用后(即使实际添加了错误引用),编辑csproj文件,查找引用,并使用特定的dll属性对其进行编辑:

<Reference Include="Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <SpecificVersion>True</SpecificVersion>  
  <HintPath>..\..\ExternalLibrary\Microsoft.Practices.EnterpriseLibrary.Logging.dll</HintPath>
</Reference>

答案 1 :(得分:0)

试试这个:

1 - Remove the reference.

2 - Clear your project bin/debug folder. If possible delete these
folders!

3 - Add the reference again.

您可能需要在上述步骤之间重新启动Visual Studio。