WCF分布式开发常见错误解决(6)Service 'WcfServiceApp.WCFService' has zero application

Posted on 2009-03-29 17:57 Frank Xu Lei 阅读(416) 评论(0)   编辑 收藏 网摘 所属分类: WCF分布式开发常见错误

调试WCF服务应用程序的时候,会出现如下错误:

“/”应用程序中的服务器错误。

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.

说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: 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.

源错误:

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

  此错误由于没有服务终结点所致。
解决办法1:在配置文件添加代码,配置服务节点:

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

解决办法2:编程方式添加服务节点

   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();
            
            }

 


 

 

老徐的博客

【作者】:Frank Xu Lei

【地址】:http://www.cnblogs.com/frank_xl/archive/2009/03/29/1424507.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值