服务具有零应用程序(非基础设施)端点 [英] Service has zero application (non-infrastructure) endpoints

查看:20
本文介绍了服务具有零应用程序(非基础设施)端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近创建了一个 WCF 服务 (dll) 和一个服务主机 (exe).我知道我的 WCF 服务工作正常,因为我能够成功地将服务添加到 WcfTestClient.

I recently created a WCF service (dll) and a service host (exe). I know my WCF service is working correctly since I am able to successfully add the service to WcfTestClient.

但是,当我从服务主机 (exe) 中使用我的 WCF 时,我似乎遇到了一个问题.我可以向我的服务主机 (exe) 添加对 WCF (dll) 的引用,并为 exe 创建必要的组件;服务安装程序、服务主机、app.config等,编译,最后使用InstallUtil安装exe.但是,当我尝试在 Microsoft 管理控制台中启动该服务时,该服务在启动后立即停止.

However, I seem to be running into an issue when I comes to utlizing my WCF from a service host (exe). I can add a reference to the WCF (dll) to my service host (exe) and create the necessary componets to the exe; such as the service installer, service host, and the app.config, compile and then finally install the exe using InstallUtil. But, when I tried to start the service in the Microsoft Management Console, the service immediately stops after being started.

所以我开始调查究竟是什么导致了这个问题,并从事件查看器的应用程序日志中发现了这个错误.

So I began investigating what could exactly be causing this issue an came up with this error from the Application Log in the Event Viewer.

说明:

服务无法启动.System.InvalidOperationException:服务服务"的应用程序为零(非基础设施)端点.这可能是因为没有配置文件已为您的应用程序找到,或因为没有服务元素匹配服务名称可以在配置文件,或者因为没有端点在服务中定义元素.

Service cannot be started. System.InvalidOperationException: Service 'Service' 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.

这个错误其实是在OnStart中产生的;我的 exe 文件,当我执行此调用 ServiceHost.Open() 时.我看过很多其他人遇到过这个问题的帖子,但是大多数(如果不是全部)声称服务名称或合同;命名空间和类名,没有被指定.我在我的配置文件中检查了这两个条目;在 exe 和 dll 中,它们完美匹配.我让办公室里的其他人在我身后仔细检查,以确保我没有一度失明,但当然他们得出的结论与我相同,一切看起来都被正确指定.我真的不知道在这一点上发生了什么.有人可以帮我解决这个问题吗?

This error is actually generated in the OnStart; of my exe, when I perform this call ServiceHost.Open(). I've seen numerous posts where other individuals have run into this issue, however most if not all of them, claim that the service name or contract; namespace and class name, are not being specified. I checked both of these entries in my config file; in the exe as well as in the dll, and they match up PERFECTLY. I've had other people in the office double check behind me to make sure I wasn't going blind at one point, but of course they came to the same conclusion as me that everything looked like it was specified correctly. I am truly at a lost as to what is going on at this point. Could anyone help me with this issue?

出现这种情况的另一个可能原因是 app.config 从未被读取;至少不是我认为应该阅读的那个.这可能是问题吗?如果是这样,我该如何着手解决这个问题.再次,任何帮助将不胜感激.

Another thing that came up as a possible reason this may be happening is that the app.config is never being read; at least not the one I think should be getting read. Could this be the issue? If so, how can I go about addressing this issue. Again, ANY help would be appreciated.

推荐答案

我刚刚遇到了这个问题,并通过将命名空间添加到服务名称中来解决它,例如

I just had this problem and resolved it by adding the namespace to the service name, e.g.

 <service name="TechResponse">

变成了

 <service name="SvcClient.TechResponse">

我还看到它通过 Web.config 而不是 App.config 解决.

I've also seen it resolved with a Web.config instead of an App.config.

这篇关于服务具有零应用程序(非基础设施)端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆