我在解决winfom中的解决方案管理器中引入了System.Messaging
可是把MessageQueue组件拖到窗体上就报错 :
创建组件"MessageQueue"失败。错误消息为:
"System.InvalidOperationException:"此计算机上尚未安装消息队列
在System.Messaging.Interop.UnsafeNativeMethods.MQGetQueueProperties(string formatName,MQPROPS queueProperties)
.....
....
想问下 该如何解决 谢谢大家!

解决方案 »

  1.   

    你的机器上要先安装上消息队列.在控制面板->添加删除程序->添加/删除Windows组件里面选择消息队列勾上即可安装
      

  2.   

    你需要安装消息队列.using System;
    “消息队列”技术允许在不同时间运行的应用程序在可能暂时脱机的异类网络和系统之间进行通信。应用程序发送、接收或查看(读取而不移除)队列中的消息。“消息队列”是 Windows 2000 和 Windows NT 的可选组件,而且必须单独安装。MessageQueue 类是“消息队列”周围的包装。“消息队列”有多个版本,而且根据所使用的操作系统的不同,使用 MessageQueue 类可能导致行为上的细微差异。有关每个“消息队列”版本的特定功能的信息,请参见 MSDN 中 Platform SDK 的“What's New in Message Queuing”(“消息队列”的新增功能)主题。using System.Messaging;namespace MyProject
    {
        /// <summary>
        /// Provides a container class for the example.
        /// </summary>
        public class MyNewQueue
        {        //**************************************************
            // Provides an entry point into the application.
            //         
            // This example demonstrates several ways to set
            // a queue's path.
            //**************************************************        public static void Main()
            {
                // Create a new instance of the class.
                MyNewQueue myNewQueue = new MyNewQueue();            myNewQueue.SendPublic();
                myNewQueue.SendPrivate();
                myNewQueue.SendByLabel();
                myNewQueue.SendByFormatName();
                myNewQueue.MonitorComputerJournal();
                myNewQueue.MonitorQueueJournal();
                myNewQueue.MonitorDeadLetter();
                myNewQueue.MonitorTransactionalDeadLetter();            return;
            }
            
            // References public queues.
            public void SendPublic()
            {
                MessageQueue myQueue = new MessageQueue(".\\myQueue");
                myQueue.Send("Public queue by path name.");            return;
            }        // References private queues.
            public void SendPrivate()
            {
                MessageQueue myQueue = new 
                    MessageQueue(".\\Private$\\myQueue");
                myQueue.Send("Private queue by path name.");            return;
            }        // References queues by label.
            public void SendByLabel()
            {
                MessageQueue myQueue = new MessageQueue("Label:TheLabel");
                myQueue.Send("Queue by label.");            return;
            }        // References queues by format name.
            public void SendByFormatName()
            {
                MessageQueue myQueue = new 
                    MessageQueue("FormatName:Public=5A5F7535-AE9A-41d4" + 
                    "-935C-845C2AFF7112");
                myQueue.Send("Queue by format name.");            return;
            }        // References computer journal queues.
            public void MonitorComputerJournal()
            {
                MessageQueue computerJournal = new 
                    MessageQueue(".\\Journal$");
                while(true)
                {
                    Message journalMessage = computerJournal.Receive();
                    // Process the journal message.
                }
            }        // References queue journal queues.
            public void MonitorQueueJournal()
            {
                MessageQueue queueJournal = new 
                    MessageQueue(".\\myQueue\\Journal$");
                while(true)
                {
                    Message journalMessage = queueJournal.Receive();
                    // Process the journal message.
                }
            }
            
            // References dead-letter queues.
            public void MonitorDeadLetter()
            {
                MessageQueue deadLetter = new 
                    MessageQueue(".\\DeadLetter$");
                while(true)
                {
                    Message deadMessage = deadLetter.Receive();
                    // Process the dead-letter message.
                }
            }        // References transactional dead-letter queues.
            public void MonitorTransactionalDeadLetter()
            {
                MessageQueue TxDeadLetter = new 
                    MessageQueue(".\\XactDeadLetter$");
                while(true)
                {
                    Message txDeadLetter = TxDeadLetter.Receive();
                    // Process the transactional dead-letter message.
                }
            }    }
    }