Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assembly Binding Redirect to a lower version

I am trying to downgrade a NServiceBus dependency so instead of using 4.0.0.0 to use 2.5.0.0

I am trying with the following ways, none of which seem to work.

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="NServiceBus"
                              publicKeyToken="9fc386479f8a226c" culture="neutral"/>
            <bindingRedirect oldVersion="4.0.0.0" newVersion="2.5.0.0"/>
        </dependentAssembly>
    </assemblyBinding>
</runtime>

I also tried with codebase :

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="NServiceBus"
                              publicKeyToken="9fc386479f8a226c"
                              culture="neutral"/>
            <codeBase version="2.5.0.0" href="NServiceBus.dll"/>
        </dependentAssembly>
    </assemblyBinding>
</runtime>

Still, nada. I went through the msdn documentation and there is no mention of using this capability in a backwards way. Is this possible?

like image 574
Konstantinos Avatar asked Jun 13 '13 17:06

Konstantinos


People also ask

What is assembly binding redirect?

Rely on automatic binding redirection This means that if two components reference different versions of the same strong-named assembly, the runtime automatically adds a binding redirection to the newer version of the assembly in the output app configuration (app. config) file.

Why does Nuget add binding redirects?

Binding redirects are added if your app or its components reference more than one version of the same assembly, even if you manually specify binding redirects in the configuration file for your app.


1 Answers

I'm actually using your first statement for some interop DLLs because the clients in our company have a different state regarding office updates. This is the code I use :

<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="office" publicKeyToken="71E9BCE111E9429C" culture="neutral"/>
    <bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="11.0.0.0"/>
  </dependentAssembly>
</assemblyBinding>

This provides backwards compatibility from version 14 of the DLL to version 11. Could you provide a link to the DLL u are using?

I've downloaded the NServiceBus framework (version 3.3.8) and investigated the DLL with ILSpy. I would suggest you do the same with your DLL. For my DLL it shows me the same public Key token as yours. Are you sure, that you use version 4.0.0.0 and not verision 3.3.0.0. Or you missmatched the public Key tokens perhaps.

like image 168
Romano Zumbé Avatar answered Sep 21 '22 19:09

Romano Zumbé