【问题标题】:Downgrade (use a lower-versioned library) with a binding redirect使用绑定重定向降级(使用较低版本的库)
【发布时间】:2011-07-15 02:22:56
【问题描述】:

我使用的是旧版本的 NHibernate (v3.0.0.1001),我坚持使用它,因为新的 LINQ 提供程序中断了我的很多查询(稍后我将尝试修复)。我想更新一个使用 NHibernate v3.1.0.4000 的库。

我尝试在 App.config 中添加绑定重定向:

<?xml version="1.0"?>
<configuration>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral"/>
                <bindingRedirect oldVersion="0.0.0.0-3.1.0.4000" newVersion="3.0.0.1001"/>
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>

但是当我编译时,我得到:

error CS1705: Assembly 'My3rdPartyDll, Version=0.5.0.170, Culture=neutral, PublicKeyToken=null' uses 'NHibernate, Version=3.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' which has a higher version than referenced assembly 'NHibernate, Version=3.0.0.1001, Culture=neutral, PublicKeyToken=aa95f207798dfdb4'

是否可以使用绑定重定向来指向降级?

【问题讨论】:

    标签: c# binding assemblies


    【解决方案1】:

    您可以使用 probing element来指定特定文件夹以找到DLL,然后您可以经过DLL进入该文件夹。

    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <probing privatePath="Assemblies"/> 
        </assemblyBinding>
    </runtime>
    

    您也可以指定要使用的特定程序集,这正是我认为您正在寻找的。​​p>

      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="WorkflowLibrary1" publicKeyToken="8afb6d596a769080" />
            <codeBase version="1.0.0.0" href="Version_1_0_0_0/WorkflowLibrary1.dll"/>
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    

    Link 对此进行了详细介绍。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-11-12
      • 1970-01-01
      • 1970-01-01
      • 2014-09-27
      • 1970-01-01
      • 2021-12-31
      • 1970-01-01
      相关资源
      最近更新 更多