Search code examples
c#asp.net.netwcfbase-address

Exception: Only an absolute URI can be used as a base address


I saw a similar problem on the site, but I checked my base address and did not notice any problems. When start debugging my project, i got this exception:Only an absolute URI can be used as a base address.

My Host Application

private ServiceHost _presenterServiceHost;
public void Start()
{ 
if(_presenterServiceHost !=null)
                    _presenterServiceHost.Close();
                _presenterServiceHost=new ServiceHost(typeof(Business.FXCTSPipeConnectionsProvider));
                _presenterServiceHost.Open();
}

Contract Implementation

public  class FXCTSPipeConnectionsProvider:IFXCTSPipeConnectionsProvider
    {
      public string Request(string query)
      {
         var response= Container.Get(query);
          return response;
      }
    }

Contract

[ServiceContract(Name ="FXCTSPipeConnectionsProvider")]
   public interface IFXCTSPipeConnectionsProvider
   {
        [OperationContract]
       string Request(string query);
   }
}

App Config

<system.serviceModel>
    <services>
      <service name="FXCTSPipeConnectionsProvider.Business.FXCTSPipeConnectionsProvider" behaviorConfiguration="ServiceBehavior">
        <endpoint address="" binding="netNamedPipeBinding" contract="FXCTSPipeConnectionsProvider.Business.IFXCTSPipeConnectionsProvider" />
        <endpoint address="mex" binding="mexNamedPipeBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.pipe://localhost:9011/FXCTSPipeConnectionsProvider" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceThrottling maxConcurrentCalls="50" maxConcurrentInstances="20" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

Solution

  • Just remove the port number and change the URL to: net.pipe://localhost/FXCTSPipeConnectionsProvider