views:

274

answers:

4

Hi

I want to write windows service in wcf After searching a lot I only found were tutorials of writing webservice in wcf not windows service.

Can any one please provide a link to any tutorial which explains how to write windows service in WCF

+2  A: 

Create your WCF service as normal, create a Windows Service and then use ServiceHost to self-host the WCF service in your Windows Service. See this MSDN page for more information about self-hosting WCF services.

Julien Lebosquain
+3  A: 

Windows services are executables. WCF applications are, generally, web services, exposed over a URI. You can host a WCF application within a windows service, not the other way around.

blowdart
exactly - you cannot write a Windows service "in WCF" - one can host a WCF service inside a NT Service....
marc_s
+3  A: 

To create a Windows service in C#, follow the step-by-step here. To make your Windows service WCF-enabled, if you will, create the System.ServiceModel.ServiceHost instance that will host your WCF service inside the OnStart() callback.

Matt Davis
+4  A: 

Good answers all of them. Just a quick note... implement your WCF service in a class library (dll) so you can then host it anywhere you like (IIS, Console App, or Windows Service).
I'd recommend starting from a console application, after your service works as expected, create a Windows Service, add a reference to you library and start the service (WCF) from there (Windows Service)

Edit: I just assumed you meant create a WCF service hosted as a Windows Service, if that's not the case please ignore my answer.

sebastian