mercredi 10 décembre 2008

CommonError#1 : WCF and how to avoid AddressAccessDeniedException in Windows Vista

It has been a very long time i haven't updated my blog.
In fact i was a little bit busy with my Imagine Cup's software (you know what it takes to write requirements, to design data bases and so on..), the good news is that we are nearly going to start coding our application.

The thing about coding, is that when you learn new technologies and start implementing them after watching a webcast or reading a tutorial is that you always face troubles, you always do mistakes !
And these issues make you searching for days about how to avoid it, it's an obvious waste of time !
And that's the purpose of this article, i want to share with you some CommonErrors that we usually make when starting with new technologies, let's go !

CommonError#1 is about this frequent mistake that we make when starting developping with WCF.

Here is the error's message (written in french) :

System.ServiceModel.AddressAccessDeniedException: HTTP n’a pas pu inscrire l’URL http://+:19296/Design_Time_Addresses/WcfServiceLibrary1/Service1/. Le processus n’a pas de droits d’accès à cet espace de noms (pour plus d’informations, voir ---> System.Net.HttpListenerException: Accès refusé

In fact, the message tell you that you have to assign the rights for a portion of the HTTP URL namespace to a particular group of users. This is called a namespace reservation.
The simplest way to do this is (if you are on vista):

1/ Open the command line as an administrator (Start->Programmes->Accesoires->right click on command and run as an administrator).

2/ Use the tool Netsh.exe like this :

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

and that's all, that should work !
For exemple, in my WCF's application i used this uri:


So what i wrote this on my command's line :

>netsh http add urlalc url=http://+:1996/Design_Time_Addresses/WcfServiceLibrary1/Service1/ user=Amokrane

Got it ?

Here is an additionnal ressource for you to read about this exception (for those of you who are using Xp, or windows server 2003 for exemple..)

I hope this first CommonError# article was helpful, just wait for the next one :)