inutan
inutan

Reputation: 10888

Multiple Services Hosted under one Windows Service

I have two Services called TemplateService, TemplateReportService (both defined in one WCF Service Library) to be exposed to the client application.

How can I host these two services under one Windows Service?

Please guide.

Thank you!

Upvotes: 0

Views: 1270

Answers (2)

Matt Davis
Matt Davis

Reputation: 46034

In the app.config for your Windows service, define a unique endpoint for each WCF service. Then in the OnStart() method of your Windows service, create a ServiceHost instance for each WCF service class.

Upvotes: 0

marc_s
marc_s

Reputation: 754250

Yes, sure, no problem - you just need to open two service hosts:

    protected override void OnStart(string[] args)
    {
        ServiceHost host1 = new ServiceHost(typeof(Service1));
        ServiceHost host2 = new ServiceHost(typeof(Service2));

        host1.Open();
        host2.Open();
    }

and of course you need to have the appropriate config entries for those two separate services in the Windows service's app.config file.

Marc

Upvotes: 3

Related Questions