Need step-by-step WCF as a Windows service

I am trying to find a (good) step by step example of creating WCF and hosting it as a Windows service (with installer). I am using VS2010 and have a simple WCF with 1 function (just returns "Hello").

Please do not submit to Google and do not publish; I am looking for a resource that someone has used. Most of the Googling that I did didn’t influence what I’m trying to do too much.

I just want to take my WCF library and find a way to install it as a Windows service. I did it in 2008, but 2010 ... Different.

+6
source share
3 answers

You just need to place the wcf contract class in your service onstart method calling ServiceHost host = new ServiceHost(YourClass) and in your service's onclose method, you need to 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 place your service in WebServiceHost , and the binding you need to use in this case is webHttpBinding .

I followed the following example and was able to create a Windows Service Host Wcf, and I am sure that this is what you are looking for a link

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

What type of clients do you want to talk about and what protocols do you want to support. All this determines your configuration.

+2
source

For future reference, for anyone watching this topic:

Here is the best example I found to look for this question: CodeProject: WCF service with Windows services hosting consumed from a C # application !

This link mentioned above shows how to use the WCF service, but with many other things to skip: MSDN: How to host the WCF service in a managed Windows service !

This second link above is suitable for creating a WCF service, but not for using it: MSDN: hosting and using WCF services !

I rarely find MSDN articles that I like :-)

+5
source

What I used when I use WCF in a Windows service, Topshelf as an infrastructure of a Windows service and a modified version of this code code to dynamically host, install and run WCF services.

Topshelf simplifies development and debugging because it can be run as a console application. The ability to dynamically update WCF service libraries without stopping the Windows service is just awesome .;)

0
source

Source: https://habr.com/ru/post/895916/


All Articles