首页 > 解决方案 > 对于 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 甚至可能与代码无关。

标签: .netibm-mq.net-assemblyassemblies

解决方案


使用如下内容创建一个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>

推荐阅读