Hosting in a Windows Service
Windows services are the most useful of the self-hosting environments for WCF services. In fact, for services deployed in a production server system, the Windows service is the only practical self-hosting choice for a few reasons:
Windows services can be configured to start when the system starts without requiring a user to log in to the machine.
The Service Control Manager can be used to manage service startup, restarts, and other run behaviors—no custom user interface required.
The service can be configured to restart when it encounters a failure, increasing overall availability.
Windows services are a self-hosting environment for WCF services, thus you write the
same code as with console and Windows hosts to initialize the ServiceHost. The main difference for Windows services is in the location where
initialization and cleanup take place. In this section I’ll walk you through creating and
deploying a Windows service and using it to host a WCF service.
I’ll provide you with a brief review of Windows services, followed by an explanation for how this relates to WCF. Then you will complete a lab that walks you through creating and testing a Windows service host. After that, I’ll discuss some scenarios for applying Windows services.
What Are Windows Services?
Windows services are applications whose lifetime is controlled through the Service Control Manager (SCM). The SCM is automatically started when a Windows machine boots, allowing local or remote control over ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access