我想从本地网络上的另一台计算机接收消息,所以我MessageQueue
以这种方式创建:
private static string QueueName = ".\\Private$\\Q1";
public void SendMessage()
{
if (!MessageQueue.Exists(QueueName))
MessageQueue.Create(QueueName);
//
}
public void ReceiveMessage()
{
// Connect to the a queue on the local computer.
MessageQueue myQueue = new MessageQueue(QueueName);
// Set the formatter to indicate body contains an Order.
myQueue.Formatter = new XmlMessageFormatter(new Type[] { typeof(Queue.Order) });
try
{
// Receive and format the message.
Message myMessage = myQueue.Receive();
///
}
我还尝试MessageQueue
使用以下格式创建我的@"MachineName\QueueName"
但收到 MessageQueueException。