2

I created a solution VS2010 C# with the WCF service, the library to get data, the service is working fine in a console application in the solution. No problem.

I have to use it on a VS2008 project (and probably later on a VS2005) for the older projects. Then I start VS2010 I get the "WCF Test Client". At this time in the VS2008, I tried to "Add a web reference" on the local machine... no result.

Then I tried to create a console application with Vs2010 to host it, I did this :

Uri baseAddress = new Uri("http://localhost:8080/hello");
using (ServiceHost host = new ServiceHost(typeof(SecurityAccessWCF.WCFSecurityService), baseAddress))
{
    // Enable metadata publishing.
    ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
    smb.HttpGetEnabled = true;
    smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
    host.Description.Behaviors.Add(smb);

    host.Open();

    Console.WriteLine("The service is ready at {0}", baseAddress);
    Console.WriteLine("Press <Enter> to stop the service.");
    Console.ReadLine();

    // Close the ServiceHost.
    host.Close();
}

I get an error on the Open(), I get this error "AddressAccessDeniedException - HTTP could not register URL... Your process does not have access rights" (the link provided is not clear, I'm on Win7 x64 as local admin and in a domain)

enter image description here

fozylet
  • 1,279
  • 1
  • 13
  • 25
TheBoubou
  • 19,487
  • 54
  • 148
  • 236

2 Answers2

5

Shift + Mouse Right Click on Visual Studio shortcut and select Run as administrator

This way you should be able to host it.

Alternately, you could build the project and run the resulting console application the same way under admin account.

Matas Vaitkevicius
  • 58,075
  • 31
  • 238
  • 265
fozylet
  • 1,279
  • 1
  • 13
  • 25
  • 1
    Alternatively, if you go to the properties for the shortcut to VisualStudio, under Compatibility, you can mark it to always run as Administrator. I ended up doing this because it was a lot easier than registering every URL that you might want to use with WCF. – CodingWithSpike Aug 01 '11 at 16:10
4

Thats a standard error meaning your application cant register the domain. Normally this is a problem on vista/windows 7 with security. Log in as administrator and run netsh http add urlacl url=http://+:80/Localhost user=DOMAIN\user

Here is a msdn article with more information

Tom Squires
  • 8,848
  • 12
  • 46
  • 72
  • I read that, it's for that I said I'm administrator and I'm not in a domain what about user=DOMAIN\USer then ? – TheBoubou Aug 01 '11 at 12:57
  • You will be on a domain. Go into computer and it will tell you which one. The user will be whatever username you logged in as. You should be able to run it as any administrator although i havent personaly tried it as anyone other than the pc administrator – Tom Squires Aug 01 '11 at 13:02