首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> .NET 網頁程式設計 >> 關於.NET

WCF 分散式開發常見錯誤 (6):Service Has Zero Application Endpoints —— 缺少端點配置或服務名稱不符

     編輯:關於.NET

IIS 託管 WCF 服務報錯:「Service 'WcfServiceApp.WCFService' has zero application endpoints」。三大原因:

  1. 找不到設定檔(web.config 未複製或路徑錯);
  2. <service> 的 name 屬性與實作類別完整名稱不符;
  3. <service> 內未定義任何 <endpoint>。

修正範例

<system.serviceModel>
  <services>
    <service name="WcfServiceApp.WCFService">
      <endpoint address="" binding="wsHttpBinding" contract="WcfServiceApp.IWCFService">
        <identity> <dns value="localhost" /> </identity>
      </endpoint>
    </service>
  </services>
</system.serviceModel>

或程式碼自託管:

using (var host = new ServiceHost(typeof(WCFService.WCFService)))
{
    host.AddServiceEndpoint(typeof(IWCFService), new NetTcpBinding(), "net.tcp://localhost:8001/WCFService");
    host.Open(); Console.Read();
}
  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved