开发者

Downgrade (use a lower-versioned library) with a binding redirect

I'm using an older version of NHibernate (v3.0.0.1001) and I'm stuck to it because the new LINQ provider breaks quite a few of my queries (something I'll be trying to fix later). I want to update a library that uses NHibernate v3.1.0.4000.

I've tried adding a binding redirect in the 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>

Bu开发者_运维问答t when I compile, I get:

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'

Is it possible to use a binding redirect to point to a downgrade?


You can use the probing Element to specify a specific folder to find the dll, and then you can just past the dll into that folder.

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

You can aslo specify a specific assembly to use which is what I think you are looking for.

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

This Link goes into more details about this.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜