Service has zero application (non

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.

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.

Description:

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.

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?

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

 <service name="TechResponse">

became

 <service name="SvcClient.TechResponse">

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


端点还应该有名称空间:

 <endpoint address="uri" binding="wsHttpBinding" contract="Namespace.Interface" />

One thing to think about is: Do you have your WCF completely uncoupled from the WindowsService (WS)? A WS is painful because you don't have a lot of control or visibility to them. I try to mitigate this by having all of my non-WS stuff in their own classes so they can be tested independently of the host WS. Using this approach might help you eliminate anything that is happening with the WS runtime vs. your service in particular.

John is likely correct that it is a .config file problem. WCF will always look for the execution context .config . So if you are hosting your WCF in different execution contexts (that is, test with a console application, and deploy with a WS), you need to make sure you have WCF configuration data moved over to the proper .config file. But the underlying issue to me is that you don't know what the problem is because the WS goo gets in the way. If you haven't refactored to that yet so that you can run your service in any context (that is, unit test or console), then I'd sugget doing so. If you spun your service up in a unit test, it would likely fail the same way that you are seeing with the WS which is much easier to debug rather than attempting to do so with the yucky WS plumbing.

链接地址: http://www.djcxy.com/p/54932.html

上一篇: 内存中的多工作流wcf实例

下一篇: 服务没有应用程序(非