3

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

Raj Kumar
  • 6,970
  • 5
  • 30
  • 40
  • 2
    What exactly do you mean by "Windows Service in WCF" - a Windows service is, roughly, a background task in the windows operating system. WCF is a communications framework so the question as written doesn't make a huge amount of sense. – Murph Nov 16 '09 at 12:06
  • Windows Service != WCF Services, Web Services, SOAP Services, etc. Completely different concept. A Windows Service is a long running application that runs in the background. WCF/Web Services pertain to SOA as a way to transport data on networks or even comm between applications running on the same machine (pipes). So.. what are you trying to accomplish? That's the real question. – Jeff LaFay Nov 10 '10 at 20:33

4 Answers4

5

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
  • 55,577
  • 12
  • 114
  • 149
  • exactly - you cannot write a Windows service "in WCF" - one can host a WCF service inside a NT Service.... – marc_s Nov 16 '09 at 12:36
4

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.

Community
  • 1
  • 1
Matt Davis
  • 45,297
  • 16
  • 93
  • 124
4

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.

sebagomez
  • 9,501
  • 7
  • 51
  • 89
2

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
  • 40,639
  • 8
  • 105
  • 117