c# - 我正忙于编写 C# IBM MQ 客户端应用程序,并不断收到 "Exception: The type initializer for ' IBM.WMQ.Nmqi.UnmanagedNmqiMQ' 抛出异常。”

标签 c# .net ibm-mq messaging

我已成功运行 MQ 客户端,并且可以使用它来获取消息。

我们已经设置了必要的环境变量: MQCHLLIB、MQCHLTAB 和 MQSSLKEYR。

.TAB 文件位于正确的文件夹中。 但是,当我执行以下代码时:

private static bool ConnectMq()
    {
        try
        {
            queueManager = new MQQueueManager("ECG_MBTST_QM", Init(false));
            queueManager.Connect();
            if (queueManager.IsConnected)
            {
                Console.WriteLine("Connected...");
            }
            return true;
        }
        catch (MQException exp)
        {
            Console.WriteLine("Exception Message: " + exp.Message); 
        }
        catch (Exception exp)
        {
            Console.WriteLine("Exception: " + exp.Message);
        }
        return false;
    }
    private static Hashtable Init()
    {
        Hashtable properties;
        properties = new Hashtable
            {
                {MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_CLIENT}
            };

        return properties;
    }

我收到了如上所述的错误消息。 我别无选择,只能使用 CCDT 文件,因为这是服务器主机指定的文件。 我相信服务器是 v7,我正在引用 v8 WMQ 库。 理论上这应该可行。

我也尝试过使用标准属性集(出于安全目的,值已更改):

properties = new Hashtable
            {
                {MQC.TRANSPORT_PROPERTY, "TCP"},
                {MQC.CHANNEL_PROPERTY, "Channel"},
                {MQC.CONNECTION_NAME_PROPERTY, "IBM_MQ_Conn"},
                {MQC.PORT_PROPERTY, "1414"},
                {MQC.HOST_NAME_PROPERTY, "IP Address"},
                {MQC.SSL_CIPHER_SPEC_PROPERTY, "TLS_RSA_WITH_AES_128_CBC_SHA"}
            };

但是当我使用上述属性时,我收到 2538 错误 - 主机不可用。 关于如何同时使用 CCDT 文件和 C#,我是否缺少某些内容?

提前致谢。

编辑 - 根据 JoshMC 的要求

这是 AMQERR01.LOG 文件中的最新条目:

1/18/2017 1:51:05 AM - Process(3272.1) User(andrewhuntley) Program( MQ app.exe)
AMQ9202: Remote host '192.168.150.102' not available, retry later.

EXPLANATION:
The attempt to allocate a conversation using TCP/IP to host '192.168.150.102'
for channel  (Exception) was not successful. However the error may be a
transitory one and it may be possible to successfully allocate a TCP/IP
conversation later. 

 In some cases the remote host cannot be determined and so is shown as '????'.
ACTION:
Try the connection again later. If the failure persists, record the error
values and contact your systems administrator. The return code from TCP/IP is 0
(X'0'). The reason for the failure may be that this host cannot reach the
destination host. It may also be possible that the listening program at host
'192.168.150.102' was not running.  If this is the case, perform the relevant
operations to start the TCP/IP listening program, and try again.
----- MQTCPConnection.cs : 357 ------------------------------------------------

请注意,服务器已启动并正在运行并且可以访问,因为我可以使用已安装的 IBM 客户端连接到它。

最佳答案

NuGet Managed IBM WebSphere MQ Client for .NET使用 IBM MQ 8.0.0.5 MQ 库。

我找到了这个 APAR IT14222来自 IBM 的消息似乎与您收到的错误消息完全匹配。

这个问题应该会在下一个修复包 8.0.0.6 中得到修复,该修复包应该在 2017 年 3 月结束之前发布。如果您有 IBM 支持契约(Contract),您还可以打开 PMR 并要求他们为您提供一份受影响的 dll,已针对 8.0.0.5 包含此 APAR 的修复程序。

关于c# - 我正忙于编写 C# IBM MQ 客户端应用程序,并不断收到 "Exception: The type initializer for ' IBM.WMQ.Nmqi.UnmanagedNmqiMQ' 抛出异常。”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41710060/

相关文章:

java - 尝试使用队列外的 GET 消息(而非 JMS)设置 MQ

javascript - LinkBut​​ton OnClick 不与数据目标和数据切换一起运行

c# - 查找名称中带有句点的元素

c# - 比较基于散列的 GUID 与“Guid.NewGuid()”时是否有更大的碰撞机会?

c# - PublicKeyToken=null 是否忽略程序集绑定(bind)?

c# - 如何从 TypeSpec 获取 TypeDef

c# - 存储对非静态方法的引用

ibm-mq - 模拟 MQSeries 服务器

ssl - com.ibm.msg.client.jms.DetailedJMSException : JMSWMQ0018: Failed to connect to queue manager 'xxx' with connection mode 'yyy' and host name 'zzz'

c# - 如何序列化 XDocument 对象?