簡體   English   中英

找不到與端點的scheme net.tcp匹配的基址

[英]Could not find a base address that matches scheme net.tcp for the endpoint

我有一個Wcf服務項目。 我的web.config中的system.serviceModel標記是:

  <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="RCISPNetTcpBinding" openTimeout="00:10:00" sendTimeout="00:10:00">
          <security mode="Transport">
            <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign">
            </transport>
            <message clientCredentialType="Windows"/>
          </security>
        </binding>
      </netTcpBinding>
    </bindings>

    <services>
      <service behaviorConfiguration="RCISP.WcfServiceBehaviour" name="RCISP.WcfService.PersonWcfService">
        <endpoint address="PersonServices" binding="netTcpBinding" bindingConfiguration="RCISPNetTcpBinding"
          contract="RCISP.Common.ServiceContract.IPersonService" >
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:40003/"/>
          </baseAddresses>
        </host>
      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="RCISP.WcfServiceBehaviour">
          <serviceMetadata httpGetEnabled="false" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <serviceAuthorization principalPermissionMode="UseWindowsGroups" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

當我想要為服務創建自托管時,我有一個運行時錯誤。

    public class ServiceFactory : ServiceHostFactory
    {
       protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
       {
          if (!IsInitialised) InitialiseService();
             return base.CreateServiceHost(serviceType, baseAddresses);
       }

    }

異常消息是:

Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http].

為什么?

你說你是自己托管服務(在你自己的過程中),但根據上面的代碼,我認為你試圖在Web應用程序內托管它。 如果是這樣,Visual Studio的Web服務器無法承載net.tcp端點。 您需要將項目設置為在IIS下運行。 請按照此處的說明操作。

如果您真的是自托管,那么您可以完全按照配置保留配置,並使用以下代碼啟動服務:

var host = new ServiceHost(typeof(Service1));
host.Open();

您需要將協議映射添加到配置文件中,以告訴它“net.tcp”協議是什么。 <bindings>部分之后添加以下內容:

<protocolMapping>
  <add scheme="net.tcp" binding="netTcpbinding"/>
</protocolMapping>    

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM