views:

134

answers:

1

I have a WCF Service Library containing five service contracts. The library is hosted through a Windows Service. Most if not all my configuration for the WCF Library is declaritive. The only thing I am doing in code for configuration is to pass the type of the class implementing the service contracts into ServiceHost. I then call Open on each of the services during the Windows Service OnStart event. Here is the error message I get:

Service cannot be started. System.InvalidOperationException: Service '[Fubu.Conversion.Service1' 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.OnBeginOpen() at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open() at Fubu.RemotingHost.RemotingHost.StartServ...

    protected override void OnStart(string[] args)
    {
        // Uncomment to debug this properly
        //System.Diagnostics.Debugger.Break();
        StartService1();
        StartService2();
        StartService3();
        StartService4();
        StartService5();
    }

Each of the above simply do the following:

    private void StartSecurityService()
    {
        host = new ServiceHost(typeof(Service1));
        host.Open();
    }

Service Lib app.congfig summary

<services>
  <service behaviorConfiguration="DefaultServiceBehavior" name="Fubu.Conversion.Service1">
    <endpoint address="" binding="netTcpBinding" bindingConfiguration="TCPBindingConfig"
      name="Service1" bindingName="TCPEndPoint" contract="Fubu.Conversion.IService1">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexTcpBinding" bindingConfiguration=""
      name="mexSecurity" bindingName="TcpMetaData" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="net.tcp://localhost:8025/Fubu/Conversion/Service1/" />
      </baseAddresses>
    </host>
  </service>

...

Contract is set up as follows: namespace Fubu.Conversion.Service1 {

[ServiceContract(Namespace = "net.tcp://localhost:8025/Fubu")]
public interface IService1
{

I have looked "high and low" for a solution without any luck. Is the answer obvious? The solution to this does not appear to be. Thanks

A: 

And the reason is painfully simple!!!! As I noted in the explanation in the question, I have a WCF Service Library being hosted within a Windows Service. I had incorrectly defined and located the app.config file within the WCF Service Library project. I ensured the app.config file always outputted to the bin folder on builds. Once I relocated or copied this config file to the Windows Service project the problem was solved and the services all 5 of them started correctly. One other point of note is to ensure the endpoints defined for the individual services are utilizing unique ports.

And the moral of the story: "Make sure you define and locate the app.config file within the project that will host your service library.

JohnL