关于System.Messaging发送与接收的问题

tigerhu76 2012-08-13 08:02:58
接收的时候路径可以使用 @"FormatName:DIRECT=TCP:192.168.1.6\Private$\myqueue" 。
但发送的时候不能使用 IP 地址,只能使用本机时的格式 @".\Private$\myqueue" ,就是说不能用 IP 地址表示,提示“无法确定具有指定格式名的队列是否存在”。

IP地址 192.168.1.6 就是我的本机地址,关闭防火墙问题依旧。

接收:
string path = @"FormatName:DIRECT=TCP:192.168.1.6\Private$\myqueue";
MessageQueue mq = new MessageQueue(path);
mq.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) });
string message = mq.Receive().Body.ToString(); //可以接收到“test message”。


发送:
string path = @".\Private$\myqueue";    //可以发送成功
//string path = @"FormatName:DIRECT=TCP:192.168.1.6\Private$\myqueue"; //出现错误
MessageQueue mq = null;
if (!MessageQueue.Exists(path))
{
mq = MessageQueue.Create(path, false);
}
else
{
mq = new MessageQueue(path);
}
mq.SetPermissions("Everyone", MessageQueueAccessRights.FullControl);
mq.Formatter = new XmlMessageFormatter(new Type[] { typeof(string) });
mq.Send("test message");


请高手指点为什么?
...全文
185 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧