I like to build and run with UAC on. When running the HttpCalculatorService example I got this error:
Unable to add URL to HTTP URL group.
Access is denied.
Running from an administrator command prompt I do not get the error!
Obviously I do not have permissions to something. Some investigation revealed that I need to add the user I wanted to run as to the urlacl (http://msdn.microsoft.com/en-us/library/cc307223(vs.85).aspx)
So this is the command that allowd me to run (replace myDOMAIN\myUSERNAME with the domain and user you wish to run the Service under): netsh http add urlacl url=http://+:80/example user=myDOMAIN\myUSERNAME.
To do this in code you could use this API: http://msdn.microsoft.com/en-us/library/aa364503(VS.85).aspx but the code your are running would need to have the necessary permissions so you are in kind of a chicken and the egg situation!
Drop me a comment and let me know if this helped you please!