Link to home
Start Free TrialLog in
Avatar of countrymeister
countrymeister

asked on

WCF - Unhandled Exception: System.ServiceModel.AddressAccessDeniedException: HTTP could not register URL

I am going through the exercises of a WCF book that I bought. I am using VS 2005 and have .NET 3.0 installed
 I get the following error when trying to debug  - Unhandled Exception: System.ServiceModel.AddressAccessDeniedException: HTTP could not register URL
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
 
namespace HelloIndigo
{
    
    [ServiceContract(Namespace="http://www.thatindigogirl.com/samples/2006/06")]
    public interface IHelloIndigoService
    {   
        [OperationContract]
        string HelloIndigo();
    }
 
    public class HelloIndigoService : IHelloIndigoService
    {
        public string HelloIndigo()
        {
            return "Hello Indigo";
        }
    }
 
}
 
 
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
 
namespace Host
{
    class Program
    {
        static void Main(string[] args)
        {
            using (ServiceHost host = new ServiceHost(typeof(HelloIndigo.HelloIndigoService), new Uri("http://localhost:8000/HelloIndigo")))
            {
                host.AddServiceEndpoint(typeof(HelloIndigo.IHelloIndigoService), new BasicHttpBinding(), "HelloIndigoService");
               
                host.Open();
                Console.WriteLine("Press <ENTER> to terminate the service host");
                Console.ReadLine();
            }
        }
    }
}
 
using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;
 
namespace Client
{
    class ServiceProxy
    {
    }
 
    [ServiceContract(Namespace = "http://www.thatindigogirl.com/samples/2006/06")]
    public interface IHelloIndigoService
    {
        [OperationContract]
        string HelloIndigo();
    }
}

Open in new window

Avatar of ZachSmith
ZachSmith
Flag of United States of America image

It looks like the URL for the example:

http://www.thatindigogirl.com/samples/2006/06

Doesn't exist. The server is returning a 404 for that URL, which is what is giving you the issue.
Avatar of countrymeister
countrymeister

ASKER

Zach,

I believe that is just a namespace, when I am hosting my service the url is http://localhost:8000/HelloIndigo


this is the remainin error string
 HTTP could not register URL http://+:8000/HelloIndigo/. Your process does not have access rights to this namespace
ASKER CERTIFIED SOLUTION
Avatar of countrymeister
countrymeister

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi
I am using VS 2010 Express on Windows 7 (64 -bit) and have a simple WCF created as follows

using System;
using System.ServiceModel;
using System.ServiceModel.Description;

namespace EssentialWCF
{
  [ServiceContract]
  public interface IStockService
  {
    [OperationContract]
    double GetPrice(string ticker);
  }

  public class StockService : IStockService
  {
    public double GetPrice(string ticker)
    {
      return 94.85;
    }
  }

  public class Service
  {
    public static void Main()
    {
      ServiceHost serviceHost = new ServiceHost(typeof(StockService));

      serviceHost.Open();

      Console.WriteLine("Press ENTER to terminate.\n\n");
      Console.ReadLine();

      serviceHost.Close();
    }
  }
}

Config file is:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="EssentialWCF.StockService" behaviorConfiguration="myServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8000/EssentialWCF"/>
          </baseAddresses>
        </host>
        <endpoint address="" binding="basicHttpBinding" contract="EssentialWCF.IStockService" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="myServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

When I debug or execute my code thru command line I get following exception. I have logged into System as Administrator

ystem.ServiceModel.AddressAccessDeniedException was unhandled
  Message=HTTP could not register URL http://+:8000/EssentialWCF/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details).
  Source=System.ServiceModel
  StackTrace:
       at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()
       at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener)
       at System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback)
       at System.ServiceModel.Channels.TransportChannelListener.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.HttpChannelListener.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Open()
       at EssentialWCF.Service.Main() in A:\Working\Projects\EssentialWCF\EssentialWCF\CodeFile1.cs:line 28
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.Net.HttpListenerException
       Message=Access is denied
       Source=System
       ErrorCode=5
       NativeErrorCode=5
       StackTrace:
            at System.Net.HttpListener.AddAllPrefixes()
            at System.Net.HttpListener.Start()
            at System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen()