visual-studiowcfwindows-7wcf-clientwcf-hosting

Visual Studio unable to open port to host WCF Service


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


Solution

  • 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.