Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法从远程MQ获取消息_C#_Ibm Mq - Fatal编程技术网

C# 无法从远程MQ获取消息

C# 无法从远程MQ获取消息,c#,ibm-mq,C#,Ibm Mq,我可以使用代码连接到远程MQ,但无法从远程MQ获取消息。我在中遇到类似System.TypeInitializationException的错误 queueGetMessageOptions[b] 请帮助任何线索将做罚款或任何文件将做罚款 我的C代码是这样的 namespace MQMessageSender { public class MQTest { public static void Main() {

我可以使用代码连接到远程MQ,但无法从远程MQ获取消息。我在中遇到类似System.TypeInitializationException的错误 queueGetMessageOptions[b]

请帮助任何线索将做罚款或任何文件将做罚款

我的C代码是这样的

  namespace MQMessageSender
  {
      public class MQTest
      {
           public static void Main()
           {
               ConnectMQ();

           }

           public static int ConnectMQ()
           {
              MQQueueManager queueManager;

              MQMessage queueMessage;
              // MQPutMessageOptions queuePutMessageOptions;
              MQGetMessageOptions queueGetMessageOptions;
              MQQueue queue;
              // Hashtable properties;
              // MQMessage message;

              string QueueName;
              string QueueManagerName;
              string ChannelInfo;
              string channelName;
              string PortNumber;
              string transportType;
              string connectionName;
              //string message;

              QueueManagerName = "*****";
              QueueName = "*******";
              ChannelInfo = "****/*****/*****/*****";
              PortNumber = "****";


              char[] separator = { '/' };
              string[] ChannelParams;
              ChannelParams = ChannelInfo.Split(separator);
              channelName = "*****";
              transportType = "MQC.TRANSPORT_MQSERIES_CLIENT";
              connectionName = "*****(****)";
              String strReturn = "";

              try
              {
                  queueManager = new MQQueueManager(QueueManagerName,
                  channelName, connectionName);
                  strReturn = "Connected Successfully";

                  queue = queueManager.AccessQueue(QueueName,
                  MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING);
                  queueMessage = new MQMessage();
                  queueMessage.Format = MQC.MQFMT_STRING;
                  queueGetMessageOptions = new MQGetMessageOptions();
                  queue.Get(queueMessage, queueGetMessageOptions);
                  strReturn = queueMessage.ReadString(queueMessage.MessageLength);
            }
            catch (MQException exp)
            {
                 strReturn = "Exception: " + exp.Message;
            }

           Console.WriteLine(strReturn);
           Console.WriteLine("Press any key to continue . . .");
           Console.ReadLine();
           return 0;
       }
错误:

“System.Transactions.Diagnostics.DiagnosticTrace”的类型初始值设定项引发异常


您的配置文件中有错误。异常告诉“无法识别的配置节参数”

请不要发布图片。发布您的实际代码和错误消息。有消息选项-在picture.saha.jan中看不到如果您试图打开的队列类型为QREMOTE,则无法打开它进行输入。另外,请不要将标签[]添加到您的问题中,因为您询问的不是IBM MQ云产品。标签[]可以回答这些问题。@JoshMc感谢您的回复:)。。我想从MQ获取消息,但在queue.get(queueMessage,queueGetMessageOptions)中获取错误;你能告诉我这个错误吗..如何解决这个问题?你的配置文件中有错误。异常告诉“无法识别的配置节参数”。@subbaraoc yes您是对的。关于类型配置有一些错误。我可以看到远程消息。非常感谢