Tag Archives: Windows 8.1

Resolving the dreaded System.ServiceModel.AddressAccessDeniedException error

I had a complex WCF service based solution working on my development PC but due to a problem when installing Windows 8.1 I had to ‘Refresh’ my PC which basically means reinstalling Windows, losing all my applications, but not my documents or data. So I had a few days of sorting out Windows, reinstalling apps and trying to get all my settings back to just the way they were before.

Now that I’ve reinstalled Visual Studio 2012 my project no longer functions correctly. When I debug a unit test the WCF Service Host displays an error:

Please try changing the HTTP port to 8733 or running as Administrator.
System.ServiceModel.AddressAccessDeniedException: HTTP could not register URL http://+:8732/Design_Time_Addresses/MyWCFService/Name/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details). —> System.Net.HttpListenerException: Access is denied

Apparently the usual solution to this is to run Visual Studio as administrator. However I’m unable to do that as the architecture we use at work requires us to reference DLLs on a network drive and network drives cannot be accessed when you run a program as administrator (aka elevated).

The other alternative of changing the port to 8733 would require editing every service, re-referencing them and then rebuilding the solution and hoping that it works (unlikely).

After a bit of digging around and research I found out that recent versions of Windows enforce security settings that prevent you from listening to any ports. I’m assuming that when Visual Studio is installed it reserves a port for it’s own use so that you can host and thus debug web services. This was the localhost:8732 port on my development machine but with reinstalling Visual studio it is now localhost:8733, unfortunately all my app.config files in the solution point to port 8732.

However this can be fixed!

Run an elevated command prompt and execute ‘netsh http show urlacl’. This displays the list of reserved ports amongst which I found this:

Reserved URL            : http://+:8733/Design_Time_Addresses/

Which, I’m assuming, is the entry added when Visual Studio was installed.

Executing the following command reserves the 8732 url/port:

‘netsh http add urlacl url=http://+:8732/ user=WORK\Robin’

Restart Visual Studio and all of a sudden my solution works again.