0

我在网站上看到了类似的问题,但我检查了我的基地址并没有发现任何问题。当开始调试我的项目时,我遇到了这个异常:只有绝对 URI 可以用作基地址。

我的主机应用程序

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

合同执行

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

合同

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

应用配置

<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>
4

1 回答 1

1

只需删除端口号并将 URL 更改为:net.pipe://localhost/FXCTSPipeConnectionsProvider

于 2017-09-27T19:19:39.497 回答