C# WCF ServiceHost 访问权限

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/885744/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 08:24:27  来源:igfitidea点击:

WCF ServiceHost access rights

c#wcfwindows-7

提问by Joshua

I get the following error when going through the WCF tutorial.

在阅读 WCF 教程时,我收到以下错误。

HTTP could not register URL http://+:8000/ServiceModelSamples/Service/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353for details).

HTTP 无法注册 URL http://+:8000/ServiceModelSamples/Service/。您的进程无权访问此命名空间(有关详细信息,请参阅http://go.microsoft.com/fwlink/?LinkId=70353)。

Is this something caused by a restriction on Windows 7?

这是由 Windows 7 的限制引起的吗?

采纳答案by Joshua

The issue is that the URL is being blocked from being created by Windows.

问题是该 URL 被 Windows 创建。

Steps to fix: Run command prompt as an administrator. Add the URL to the ACL

修复步骤:以管理员身份运行命令提示符。将 URL 添加到 ACL

netsh http add urlacl url=http://+:8000/ServiceModelSamples/Service user=mylocaluser

回答by Stephen Newman

If you are running via the IDE, running as administrator should help. To do this locate the Visual Studio 2008/10 application icon, right click it and select "Run as administrator"

如果您通过 IDE 运行,以管理员身份运行应该会有所帮助。为此,请找到 Visual Studio 2008/10 应用程序图标,右键单击它并选择“以管理员身份运行”

回答by Anitesh Kumar.

I am working on Windows Vista. Even i faced the same problem but when i tried to run VS 2008 with administrative privileges, the issue resolved and my service was up and running. :)

我在 Windows Vista 上工作。即使我也遇到了同样的问题,但是当我尝试以管理权限运行 VS 2008 时,问题解决了,我的服务已启动并正在运行。:)

回答by Davide Icardi

Another solution is to use the address

另一种解决方案是使用地址

http://localhost:8732/Design_Time_Addresses/YOUR_ADDRESS.

http://localhost:8732/Design_Time_Addresses/YOUR_ADDRESS

.NET Framework (3.5) automatically register this address (http://*:8732/Design_Time_Addresses) for debugging scope. This is useful when you need to host services inside visual studio for debugging or testing. Don't use this on production...

.NET Framework (3.5) 自动注册此地址 (http://*:8732/Design_Time_Addresses) 用于调试范围。当您需要在 Visual Studio 内托管服务以进行调试或测试时,这非常有用。不要在生产中使用它...

回答by Vicky

Open Visual Studio as an Administrator.. It will run.

以管理员身份打开 Visual Studio.. 它将运行。

回答by Palnati

please open your Visual Studio in Administration Mode then try it.

请在管理模式下打开您的 Visual Studio,然后尝试。

回答by Doro

Running Visual Studio as administrator could fix the issue, but if you use Visual Studio with for example TortoiseSVN, you cannot commit any changes. Another possible solution would be to run the service as administrator and the rest Visual Studio as local user.

以管理员身份运行 Visual Studio 可以解决该问题,但如果您将 Visual Studio 与 TortoiseSVN 等一起使用,则无法提交任何更改。另一种可能的解决方案是以管理员身份运行服务,其余的 Visual Studio 以本地用户身份运行。

回答by Metin Atalay

Open a command prompt as the administrator and you write below command to add your URL:

以管理员身份打开命令提示符,然后编写以下命令来添加 URL:

netsh http add urlacl url=http://+:8000/YourServiceLibrary/YourService user=Everyone

few points to keep in mind:

要记住的几点:

  1. change the port as per your coding
  2. change the service library name as per your library name
  3. "YourService" is optional
  1. 根据您的编码更改端口
  2. 根据您的库名称更改服务库名称
  3. “您的服务”是可选的

for more info you can check: Configuring HTTP and HTTPS

有关更多信息,您可以查看: 配置 HTTP 和 HTTPS

回答by lalit

Please open your Visual Studio as administrator:

请以管理员身份打开您的 Visual Studio:

enter image description here

在此处输入图片说明

回答by Lucaseto

Other option that work is ..,

其他可行的选择是..,

If you change de indentity in application pool, you can run the code, the idea is change the aplication pool execution account for one account with more privileges,

如果更改应用程序池中的de indentity,则可以运行代码,思路是将应用程序池执行帐户更改为具有更多权限的帐户,

For more details use this blog

有关更多详细信息,请使用此博客

https://letrasandnumeros.com/2017/11/27/http-could-not-register-url-http-80-hellowcf-your-process-does-not-have-access-rights-to-this-namespace/

https://letrasandnumeros.com/2017/11/27/http-could-not-register-url-http-80-hellowcf-your-process-does-not-have-access-rights-to-this-namespace/