2012-03-15 78 views
1

我有一個Wcf服務項目。在我的web.config system.serviceModel標籤:無法找到與端點模式net.tcp匹配的基地址

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

爲什麼?

+0

退房http://stackoverflow.com/questions/1793119/could-not-find-a-base-address-that-matches-scheme-net-tcp – 2012-03-15 15:03:48

+0

@wise_guybg:我讀過這個問題,但是我的問題沒有解決。 – Ehsan 2012-03-15 15:44:05

回答

1

您需要添加一個協議映射到您的配置文件,告訴它「net.tcp」協議是什麼。您<bindings>節之後補充一點:

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

我添加它,但我的問題沒有解決。 – Ehsan 2012-03-17 10:15:16

2

你說你是自我託管服務(自己的過程中),但基於上面的代碼,我想你想駐留在Web應用程序內部。如果是這樣,Visual Studio的Web服務器不能託管net.tcp端點。您需要將項目設置爲在IIS下運行。請按照說明here

如果你是真正的自我託管比你可以離開配置到底你擁有它,使用下面的代碼旋轉起來的服務:

var host = new ServiceHost(typeof(Service1)); 
host.Open(); 
相關問題