【问题标题】:Reference alternate to reference assembly in Visual Studio 2010?在 Visual Studio 2010 中参考替代参考程序集?
【发布时间】:2012-01-26 23:05:17
【问题描述】:

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

我可以禁用此行为吗?

【问题讨论】:

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


    【解决方案1】:

    如果 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>
    

    【讨论】:

    • 我无法标记Specific Version = true,除非先添加引用。
    • 这样做,加上找到替换程序集的新强名称,效果很好。谢谢!
    • P.S.你也想做&lt;Private&gt;True&lt;/Private&gt;,所以Copy Local;否则在部署时你会遇到问题。
    【解决方案2】:

    试试这个:

    1 - Remove the reference.
    
    2 - Clear your project bin/debug folder. If possible delete these
    folders!
    
    3 - Add the reference again.
    

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

    【讨论】:

    • 尝试在 Visual Studio 中运行 Clean 解决方案命令...您确定可以在 .NET 4.0 中使用此替代 DLL 吗?它是否支持.NET 4?也看看这个:stackoverflow.com/questions/5575253/old-dll-keeps-being-used
    • 也尝试过清洁。 DLL 绝对支持 .NET 4.0。
    • 很遗憾,我无法从 GAC 中删除核心 DLL,因此该解决方案无法正常工作。
    猜你喜欢
    • 2014-01-27
    • 2010-12-15
    • 1970-01-01
    • 2011-12-25
    • 1970-01-01
    • 2012-11-04
    • 1970-01-01
    • 1970-01-01
    • 2012-12-21
    相关资源
    最近更新 更多