четверг, 8 ноября 2012 г.

AddressAccessDeniedException running HTTP WCF Endpoint

===============
Link to original post @stuarthallows.wordpress.com
===============


March 29, 2011 — Stuart Hallows
So you’ve read the book on WCF, you eagerly write your first service, configure up an HTTP endpoint, run your service and BOOM, you get the following error;

AddressAccessDeniedException was unhandled.


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

No need to fret, it’s pretty easy to resolve. What’s happening is that on Vista and Windows 7 you don’t by default have the necessary rights to run an HTTP service, all HTTP addresses are reserved for administrative accounts. There’s a few options here to acquire the rights if you’re running as non-admin;

Run Visual Studio under an administrator account
Run the actual WCF HTTP service host application under an administrator account
Edit the App.manifest file and set the requestedExecutionLevel level attribute to requireAdministrator to prompt Windows UAC to ask you for administrator credentials.
The final option, and perhaps the best, is to use netsh to grant yourself the right to run HTTP services on a particular port number. You’ll need to open up a command prompt as administrator, an easy way to do this is to type cmd into the Start | Run box, then hit CRTL + SHIFT + ENTER. Then type the following, replacing the port number and user name with suitable values.

netsh http add urlacl url=http://+:8000/ user=MACHINE\USER

Hopefully that’ll all work and you’ll have yourself a nice little HTTP WCF endpoint. You can check that you’ve been granted the rights to host on the port number as follows;

netsh http show urlacl

Which should show something along these lines.

Reserved URL            : http://+:8000/
User: MyMachine\UserName
Listen: Yes
Delegate: No
SDDL: D:(A;;GX;;;S-1-6-21-5890517954-2574697971-1313458528-1004)


http://stuarthallows.wordpress.com/2011/03/29/addressaccessdeniedexception-running-http-wcf-endpoint/ (C)

Комментариев нет:

Отправить комментарий