这篇文章主要介绍了WCF出错怎么办,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。
1. 运行self-hosting之后报错:
System.ServiceModel.AddressAccessDeniedException' occurred in System.Servic
System.ServiceModel.AddressAccessDeniedException: ... http://+:9999/calculatorService/...
以管理员权限运行cmd,解决HTTP名字空间保护的问题。打开了cmd之后,运行
"netsh http add urlacl http://+:9999/calculatorService/ user=everyone"
2.
System.ServiceModel.CommunicationObjectFaultedException
The communication object, System.ServiceModel.ServiceHost, cannot be used for communication
并且查看stack 中显示 timeout,猜想估计是权限不够,重启vs,右击选择属性->兼容性->以管理员身份运行。
成功
3.
'System.ServiceModel.Security.SecurityNegotiationException' occurred in mscorlib.dll
Additional information: SOAP security negotiation with 'http://xlt1159-cn1:9999/messageService' for target 'http://xlt1159-cn1:9999/messageService' failed. See inner exception for more details.
问题:WCF的安全问题,如果不需要考虑安全性,最简单的方法将security.mode 设置为Node。
如在service中添加代码:
WSHttpBinding wsb = new WSHttpBinding();
wsb.Name = "TestBinding";
wsb.Security.Mode = SecurityMode.None;
在 client中添加代码:
WSHttpBinding wsb = new WSHttpBinding();
wsb.Name = "TestBinding";
wsb.Security.Mode = SecurityMode.None;
wsb.Security.Message.ClientCredentialType = MessageCredentialType.None;
(https://msdn.microsoft.com/en-us/library/ms731925.aspx)
4. WCF服务端如果是remote的,需要在服务端要打开端口号,在防火墙中新增规则。
感谢你能够认真阅读完这篇文章,希望小编分享的“WCF出错怎么办”这篇文章对大家有帮助,同时也希望大家多多支持亿速云,关注亿速云行业资讯频道,更多相关知识等着你来学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。