Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
281 views
in Technique[技术] by (71.8m points)

c# - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...