利用
public static void SendComStr(string strPath,string data,string strTitle)
{
    MessageQueue q = new System.Messaging.MessageQueue(strPath);
q.Formatter=new ActiveXMessageFormatter();
    q.Send(data,strTitle);
}
在windows 2003 server中调用此方法发送MQ消息,程序能正常运行,但隔一段时间后,再次运行就会出现“此计算机上尚未安装“消息队列”。的异常,需要切换到另一个应用程序池方可继续运行,如此往复,不知道是何原因,求高手解答,消息队列已重装了n次。。靠

解决方案 »

  1.   

    你的代码在创建并使用MessageQueue以后没有释放资源,导致资源耗尽。请在每次使用MessageQueue完毕后及时调用MessageQueue.Close()方法释放资源.        public void SendMessage()
            {
                // Connect to a queue on the local computer.
                MessageQueue myQueue = new MessageQueue(".\\myQueue");            // Send a message to the queue.
                myQueue.Send("My message data1.");
                
                // Explicitly release resources.
                myQueue.Close();            return;
            }
      

  2.   

    上面的例子用try{}catch{}保护一下更好。