WCF distributed development Common error resolution (6)

Source: Internet
Author: User

WCF distributed development Common error Resolution (6) Service ' Wcfserviceapp.wcfservice ' has zero application

When you debug a WCF service application, you receive the following error:

“/”应用程序中的服务器错误。Service 'WcfServiceApp.WCFService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.

Note: An unhandled exception occurred during the execution of the current WEB request. Check the stack trace for more information about the error and where the error occurred in the code.

Exception Details:

System.InvalidOperationException: Service 'WcfServiceApp.WCFService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.

SOURCE Error:

执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪信 息确定有关异常原因和发生位置的信息。

This error is not caused by a service endpoint.

Workaround 1: Add code to the configuration file to configure the service node:

<endpoint address="" binding="wsHttpBinding" contract="WcfServiceApp.IWCFService">
<!--
  Upon deployment, the following identity element should be removed or replaced to reflect the
  identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity
  automatically.
-->
<identity>
  <dns value="localhost"/>
</identity>
</endpoint>

Workaround 2: Add service nodes programmatically

using (ServiceHost host = new ServiceHost(typeof (WCFService.WCFService)))
{
   Uri tcpAddress = new Uri("net.tcp://localhost:8001/WCFService");
   host.AddServiceEndpoint(typeof(WCFService.IWCFService), new NetTcpBinding() , tcpAddress);
   if (host.State ! =CommunicationState.Opening)
     host.Open();
   //显示运行状态
   Console.WriteLine("Host is runing! and state is {0}",host.State);
   //等待输入即停止服务
   Console.Read();

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.