Need a step-by-step WCF as Windows Service Need a step-by-step WCF as Windows Service windows windows

Need a step-by-step WCF as Windows Service


For future reference - for anyone else looking at this thread:

Here is the best example I've found for what this question was looking for:CodeProject: WCF Service with Windows Service Hosting, consumed from C# App!

This link mentioned above shows how to consume the WCF service, but with a lot of other stuff to wade through: MSDN: How to: Host a WCF Service in a Managed Windows Service!

This second link above is good for creating the WCF service, but not for consuming it: MSDN: Hosting and Consuming WCF Services!

I rarely find MSDN articles that I like :-)


You just need to host the wcf contract class in your onstart method of service calling ServiceHost host = new ServiceHost(YourClass) and in onclose method of your service you need call host.close(). The hosting option depends on what type of clients you want to talk to if you want to talk to pure html clients using REST you need to host your service in WebServiceHost and the binding you need to use in that case is webHttpBinding.

I have followed the following example and was able to create windows service hosted wcf and im sure this what you are looking for link

I did not find any difference in creating wcf service in vs2008 and vs2010.

What type of clients do you want to talk and which protocols do you want to support. This all defines your configuration.


What I've used when I use WCF in a Windows Service is Topshelf as a Windows service framework and a modified version of this Code Project code to dynamically host, install and run WCF services.

Topshelf makes it very easy to develop and debug because it can be run as a console application. Being able to dynamically update WCF service libraries without stopping the Windows service is just cool. ;)