c# - 程序集绑定(bind)重定向到较低版本

标签 c# .net assembly-binding-redirect

我正在尝试降级 NServiceBus 依赖项,而不是使用 4.0.0.0 来使用 2.5.0.0

我正在尝试以下方法,但似乎都不起作用。

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

我也试过代码库:

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

仍然,虚无。我浏览了 msdn 文档,但没有提及以向后方式使用此功能。这可能吗?

最佳答案

我实际上将您的第一个语句用于某些互操作 DLL,因为我们公司的客户在办公室更新方面有不同的状态。这是我使用的代码:

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

这提供了从 DLL 版本 14 到版本 11 的向后兼容性。你能提供你正在使用的 DLL 的链接吗?

我已经下载了 NServiceBus 框架(版本 3.3.8)并使用 ILSpy 研究了 DLL。我建议你对你的 DLL 做同样的事情。对于我的 DLL,它向我显示了与您相同的公钥 token 。您确定您使用的是 4.0.0.0 版而不是 3.3.0.0 版吗?或者您可能不匹配公钥 token 。

关于c# - 程序集绑定(bind)重定向到较低版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17092928/

相关文章:

.net - 将 bindingRedirect 添加到 .Net 标准库

f# - 对于 F# 类型提供程序,如何为依赖程序集执行绑定(bind)重定向?

c# - 程序集绑定(bind)重定向 : How and Why?

c# - 将 Func 传递到 Where 并使用 IQueryable

c# - 如何使用 C# 取消删除文件?

c# - 更新 zip 时出现内存不足异常

c# - 如何找出以编程方式构建 dll 的 .net 运行时?

c# - .NET 错误处理

c# - MongoDB C# 单声道

c# - 为 C# 设置枚举