HTTP could not register URL http://+:8000/HelloWCF/. Your process does not have access rights to this namespace

前端 未结 9 1862
遥遥无期
遥遥无期 2020-11-27 10:10

I\'m a beginner in WCF, but trying to improve my experience. And on the first step I faced the problem. I created the simplest WCF service. The listing of code: (all the cod

相关标签:
9条回答
  • 2020-11-27 10:42

    In Windows Vista and later the HTTP WCF service stuff would cause the exception you mentioned because a restricted account does not have right for that. That is the reason why it worked when you ran it as administrator.

    Every sensible developer must use a RESTRICTED account rather than as an Administrator, yet many people go the wrong way and that is precisely why there are so many applications out there that DEMAND admin permissions when they are not really required. Working the lazy way results in lazy solutions. I hope you still work in a restricted account (my congratulations).

    There is a tool out there (from 2008 or so) called NamespaceManagerTool if I remember correctly that is supposed to grant the restricted user permissions on these service URLs that you define for WCF. I haven't used that though...

    0 讨论(0)
  • Your sample code won't work as shown because you forgot to include a Console.ReadLine() before the serviceHost.Close() line. That means the host is opened and then immediately closed.

    Other than that, it seems you have a permission problem on your machine. Ensure you are logged-in as an administrator account on your machine. If you are an administrator then it may be that you don't have the World Wide Web Publishing Service (W3SVC) running to handle HTTP requests.

    0 讨论(0)
  • 2020-11-27 10:45

    The simple thing you need to do is to close your Visual Studio environment and open it again by using 'Run as administrator'. It should now run successfully.

    0 讨论(0)
  • 2020-11-27 10:45

    Close iis express and all the browsers (if the url was opened in any of the browser). Also open the visual studio IDE in admin mode. This has resolved my issue.

    0 讨论(0)
  • 2020-11-27 10:47

    Unfortunately the link in the exception text, http://go.microsoft.com/fwlink/?LinkId=70353, is broken. However, it used to lead to http://msdn.microsoft.com/en-us/library/ms733768.aspx which explains how to set the permissions.

    It basically informs you to use the following command:

    netsh http add urlacl url=http://+:80/MyUri user=DOMAIN\user

    You can get more help on the details using the help of netsh

    For example: netsh http add ?

    Gives help on the http add command.

    0 讨论(0)
  • 2020-11-27 10:55

    Right Click on Visual Studio > Run as Administrator > Open your project and run the service. This is a privilege related issue.

    0 讨论(0)
提交回复
热议问题