.NET assembly binding, can I map an assembly to a version in another assembly?

纵然是瞬间 提交于 2019-12-10 17:12:46

问题


Good Morning, Is it possible to map assembly requests to the version within another assembly? For instance our product uses NHibernate 3.2. We are moving to NServiceBus 3.2.2. For DBSubscription storage it uses NHibernate and it's baked in version of NHibernate which is 3.3 in NServiceBus.NHibernate.

How can I map requests for NHibernate 3.2.0.2002 to NServiceBus.NHibernate which is 3.3...

<assemblyIdentity name="NHibernate"
                          publicKeyToken="aa95f207798dfdb4"
                          culture="neutral" />
        <bindingRedirect oldVersion="3.2.0.2002"
                         newVersion="3.3.0.4000"/> //I need it to be NServiceBus.NHibernate

Thanks for any tips or tricks. Samples and Links are always appreciated.

Thanks All!


回答1:


In your binding redirect you can redirect to a different code base using the codeBase element:

<dependentAssembly>
    <assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
    <bindingRedirect oldVersion="3.2.0.2002" newVersion="3.3.0.4000"/>
    <codeBase version="3.3.0.4000" href="file:///C:/path/to/assembly.dll" />
</dependentAssembly>

The public keys must be the same, however. You can not bind to a different assembly that is signed with a different key.

If the keys are different, then you need to recompile your solution against NServiceBus.NHibernate.



来源:https://stackoverflow.com/questions/11126593/net-assembly-binding-can-i-map-an-assembly-to-a-version-in-another-assembly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!