WCF分布式开发常见错误(19):There was an error opening the queue打开消息队列出错

Posted on 2009-06-17 00:39 Frank Xu Lei 阅读(1429) 评论(9)   编辑 收藏 网摘 所属分类: WCF分布式开发常见错误

    在调试托管宿主 WCF MSMQ消息队列代码的时候出现错误:

    There was an error opening the queue. Ensure that MSMQ is installed and running, the queue exists and has proper authorization to be read from. The inner exception may contain additional information.

    打开队列有一个错误,确保MSMQ已经安装或者运行,队列存在和有读权限。异常内部也许包含额外的信息。

解决办法:

 NetMsmqBinding queBinding  =   new  NetMsmqBinding(NetMsmqSecurityMode.None);
                queBinding.ExactlyOnce 
=   false ;
                queBinding.Security.Message.ClientCredentialType 
=  MessageCredentialType.UserName;

                
//  添加服务终结点

                host.AddServiceEndpoint(
typeof (WCFService.IWCFMSMQService), queBinding, queBaseAddress);

 

                
// 判断是否以及打开连接,如果尚未打开,就打开侦听端口
                 if  (host.State  != CommunicationState.Opening)
                host.Open();

   注意:

1. NetMsmqBinding queBinding = new NetMsmqBinding(NetMsmqSecurityMode.None);消息无安全模式;
2. queBinding.ExactlyOnce = false;绑定消息只能读取一次的属性设置为false;

3.使用 host.AddServiceEndpoint(typeof(WCFService.IWCFMSMQService), queBinding, queBaseAddress);
添加终结点。

  注意配置文件里的设置注销掉,只使用代码来设置,最后启动宿主即可。

    参考文章:

http://social.msdn.microsoft.com/forums/en-US/wcf/thread/7ceeb231-2ff4-4431-9d61-dc071b916788

老外也遇到这个问题,讨论的也比较多,但是我修改了安全模式才解决掉。

 


 

老徐的博客

【作者】:Frank Xu Lei

【地址】:http://www.cnblogs.com/frank_xl/archive/2009/06/17/1504695.html

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值