.net - 对于 IBM.WMQ .Net 参考,为什么我的代码没有加载应用程序特定版本的 amqmdnet.dll?
问题描述
我有一个定制版本的 amqmdnet.dll,它在我的本地项目中引用,并与应用程序一起部署。
这是在我们的应用程序运行并与 IBM 队列交互的服务器的日志中
System.IO.FileLoadException: Could not load file or assembly '' or one of its dependencies.
General Exception (Exception from HRESULT: 0x80131500)
File name: 'amqmdnet, Version=7.5.0.0, Culture=neutral, PublicKeyToken=dd3cb1c9aae9ec97'
at IBM.WMQ.MQDestination.Put(MQMessage message)
但是,项目文件 (.csproj) 引用了完全不同版本的 amqmdnet.dll
<Reference Include="amqmdnet, Version=9.0.5.0, Culture=neutral, PublicKeyToken=dd3cb1c9aae9ec97, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>IBM\amqmdnet.dll</HintPath>
</Reference>
我们在这里与许多问题搏斗
- 在服务器日志中,为什么 amqmdnet dll 的版本号显示为具有相同公钥令牌的 7.5.0.0,即使我们部署了 9.0.3.0 版本?服务器上没有安装 IBM 客户端(它是一个准系统 Azure 容器)。
- 仅当调用 Put 方法时才会引发异常。在此之前,很多初始化都没有问题,例如。MQQueue 对象的初始化等等。为什么正确程序集 (9.0.3.0) 的 Put 方法试图从不同的程序集版本 (7.5.0.0) 调用方法?
更新 这是由于系统问题,重新启动似乎可以解决它。它仍然没有告诉我们问题发生的原因,但它与 amqmdnet 甚至可能与代码无关。
解决方案
使用如下内容创建一个app.config
以确保程序使用特定版本的amqmdnet.dll
.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="amqmdnet" publicKeyToken="dd3cb1c9aae9ec97" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-9.0.3.0" newVersion="9.0.3.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
推荐阅读
- android - 自动缩放
- android - startactivity后的接口回调
- javascript - 无法读取未定义组件的属性“nativeElement”
- c++ - 编译器可以优化不相关的命令以使用不同的内核执行吗?
- post - 你可以点击一个 URL 并做一个大的跨域 POST 请求吗?
- ruby-on-rails - 将数据从表单传输到数据表
- kubernetes - 如何安排 Pod 重启
- qemu - 使用 QEMU 内置的 gdbserver 来调试在 QEMU 的来宾操作系统中运行的程序是否可行?
- c++ - 如何将模态位置设置为屏幕左下角?
- elasticsearch - 使用 ELK 进行防火墙审查