C#运行WCF服务出现HTTP could not register URL错误的解决方案(含简单解决)
本文来源:C#运行WCF服务出现HTTP could not register URL错误的解决方案(含简单解决)
今天在WIN 8.1的电脑上写了个C# WCF的测试服务,程序的代码写好,运行的时候却出现如下错误:
异常:An unhandled exception of type ‘System.ServiceModel.AddressAccessDeniedException’ occurred in System.ServiceModel.dll
Additional information: HTTP could not register URL
http://+:8080/hello/. Your process does not have access rights to this
namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for
details).
怎么办,以前从来没遇到过这种错误啊,于是去GOOGLE找答案,发现原来是WIN7/WIN8/VISTA的安全设置引起,说可以用”netsh.exe“命令来解决,具体的命令如下:
以管理员身份运行命令提示符窗口,键入命令
netsh http add urlacl url=http://+:8080/ user=DOMAIN\UserName
我自己试了一下,没有作用,不知道参数怎么配置(下载了工具HttpNamespaceManager在WIN 8.1下也不能正常运行),不管了。
还有一种更为快捷的解决方案,就是以管理员的身份来运行Visual Studio,赶紧试一下,以管理员身份打开,再运行之前的WCF服务,果然程序正常运行了。
本文参考资料:http://www.cnblogs.com/think8848/archive/2011/07/24/2115295.html
专注.NET开发的爱好者知识社区--【https://codedefault.com】。