I'm trying to host a WCF Service inside a Windows Service which I am starting through a console app. Each service is its own project as is the console app. I've copied the app.config from the WCF Service library into the app.config of the console app, but I keep getting "Service has zero application endpoints...". I've read in a few places that the error means my type references are not fully qualified, but I've double (triple, quadruple...) checked that. And I'm pretty sure I have an app.config. There are 3 exes in my debug directory: Console App, Console App vshost, Win Service. The Win Service didn't have an app.config, so I tried copying its app.config in case it was looking for it, but no luck. I also checked to make sure the configs were named correctly (<program>.exe.config).
Here's what I'm using. My console app creates an instance of JobSchdeuler
and calls JobSchedulerConsoleStart
.
Host Code:
public partial class JobScheduler : ServiceBase
{
ServiceHost jobServiceHost = null;
public JobScheduler()
{
ServiceName = "JobSchedulerService";
InitializeComponent();
}
#region Service Init/Uninit
/// <summary>
/// OnStart
/// </summary>
/// <param name="args"></param>
protected override void OnStart(string[] args)
{
if (jobServiceHost != null)
{
jobServiceHost.Close();
}
jobServiceHost = new ServiceHost(typeof(JobSchedulerWCF.JobService));
jobServiceHost.Open();
}
/// <summary>
/// OnStop
/// </summary>
protected override void OnStop()
{
if (jobServiceHost != null)
{
jobServiceHost.Close();
jobServiceHost = null;
}
}
#endregion
#region Debugging
public void JobSchedulerConsoleStart()
{
this.OnStart(null);
Console.WriteLine("Service Started.");
ProcessInput();
Console.WriteLine("Service Stopped.");
this.OnStop();
}
private void ProcessInput()
{
Console.WriteLine("Press any key to quit...");
Console.ReadKey();
}
#endregion
}
app.config
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="JobSchedulerWCF.Service1Behavior" name="JobSchedulerWCF.JobService, JobSchedulerWCF">
<endpoint address="" binding="wsHttpBinding" contract="JobSchedulerWCF.IJobServiceController, JobSchedulerWCF">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:12345/jobService"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="JobSchedulerWCF.Service1Behavior">
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>