WCF library in Windows service common error
Service '<ServiceName>' 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.
at System.ServiceModel.Description.DispatcherBuilder.EnsureThereAreNonMexEndpoints(ServiceDescription description)
at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost)
at System.ServiceModel.ServiceHostBase.InitializeRuntime()
at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at <ServiceName>.Service1.OnStart(String[] args) in
This problem is for when you have a WCF library and your integrating it into a Windows service.
Ok check the following. When you added your app.config file from the WCF library into your windows service did you alter the name?
What I mean is:
<Service name=”Namespace” + “Type” ....
When you copied it over it had the old namespace and type from the WCF library. In your windows service alter the app.config to match your service as per example below.
namespace TestServiceNamespace
{
class TestTypeService: ServiceBase
{
}
}
The service name would be testNamespace in the windows servioce
<Service name=” TestServiceNamespace.TestTypeService” ....
Hopefully this saves you a piece of time..
Comments
Anonymous
September 15, 2009
but the Service tag is for exposing the wcf service, right? so, it should be the wcf service name, not the windows service name (this one, inheriting from ServiceBase)Anonymous
October 05, 2009
I still got this error Could it be related to IIS6? I use Windows Server 2003 with IIS6. Maybe only IIS7 and above could handle integrated WCF libraries into a web services. Some details: Compile settings: https://dl.getdropbox.com/u/1380448/Compile%20settings.png IService definition: https://dl.getdropbox.com/u/1380448/ISerivce1.png App.config: <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.serviceModel> <services> <service name="WcfServiceLibrary1.Service1" behaviorConfiguration="WcfServiceLibrary1.Service1Behavior"> <host> <baseAddresses> <add baseAddress = "http://mgruys.nl/Service1" /> </baseAddresses> </host> <endpoint address ="" binding="wsHttpBinding" contract="WcfServiceLibrary1.IService1" /> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> <behaviors> <serviceBehaviors> <behavior name="WcfServiceLibrary1.Service1Behavior"> <serviceMetadata httpGetEnabled="True"/> <serviceDebug includeExceptionDetailInFaults="True" /> </behavior> </serviceBehaviors> </behaviors> <bindings> <wsHttpBinding> <binding name="ServiceLibrary1Binding"> <security/> </binding> </wsHttpBinding> </bindings> </system.serviceModel> </configuration> Web.Config: <system.serviceModel> also pasted in web.config I have created the virtual directory WcfServiceLibrary1 in IIS. Given Execute permission to this Virtual Dir. Placed the .svc dile in the WcfServiceLibrary1 folder with the foll. code. <%@ ServiceHost Service="WcfServiceLibrary1.Service1" %> <%@ Assembly Name="WcfServiceLibrary1" %> Still I got this error when I try access the service page https://dl.getdropbox.com/u/1380448/error.png Any help or hints are are welcome Thanks in advanceAnonymous
October 05, 2009
Problem solved. Wrong configuration of Service Endpoints in the Web.config file. This configuration file 'Web.config' seems to be very, very important.... One little mistake in it and you get this kind of errors. Regards, MichaelAnonymous
October 06, 2009
Thats great, I was trying to find some time to have a look at it. A thing Id recommend is you watch this Channel9 broadcast from MSDN which goes through the endpoints in detail. Thats if you already havent.. its quite good ;-) http://channel9.msdn.com/posts/cliff.simpkins/Endpoint-Screencasts-Configuring-Services-with-Endpoints/ Best of luck KeithAnonymous
October 06, 2009
Really interesting Channel9 broadcast from MSDN. Thanks for sharing.