Windows Services



Windows Services

OBJECTIVES

This chapter covers the following Microsoft-specified objective for the "Creating and Managing Microsoft Windows Services, Serviced Components, .NET Remoting Objects, and XML Web Services" section of the "Developing XML Web Services and Server Components with Microsoft Visual C# .NET and the Microsoft .NET Framework" exam:

Create and manipulate a Windows service.

  • Write code that is executed when a Windows service is started or stopped.

  • Many enterprise applications need components that run in the background and provide important services to other application components and users on an ongoing basis.

    A standard way to create these types of components on the Windows operating system is in the form of Windows services. The programming model provided by the Microsoft .NET Framework makes it easy to design and implement Windows services like never before.

    This exam objective requires you to know how to use the Microsoft .NET Framework to create and manipulate Windows services.

OUTLINE

Introduction

Understanding Windows Services

Architecture of Windows Services

Windows Service Database

Service Control Manager (SCM)

Windows Service Installer

Windows Services in Execution

Windows Service Controller Program

The FCL Support for Windows Services

Creating a Windows Service Application

The System.ServiceProcess.ServiceBase Class

Understanding How the SCM Interacts with a Windows Service

Creating the OrderService Application

Installing a Windows Service

The ServiceProcessInstaller and the ServiceInstaller Classes

Adding Installer Classes to a Windows Service Project

Using Installer Tool (installutil.exe) to Install a Windows Service Application

Starting and Testing a Windows Service

Using Tools to Monitor and Control a Windows Service

Using the Services MMC Snap-in

Using Visual Studio .NET Server Explorer

Using the NET Utility (net.exe)

Using the Service Control Utility (sc.exe)

Controlling a Windows Service

The ServiceController Class

Creating a Windows Service Controller Application

Chapter Summary

Apply Your Knowledge

STUDY STRATEGIES

  • Understand the reasons why you would implement some applications as Windows services.

  • Write programs to create a Windows Service. Make sure that you complete Guided Practice Exercise 6.1.

  • Use installutil.exe to install a Windows service. Study Chapter 10, "Deployment," to learn more about the installation process and to learn how to create a setup package based on Windows installer technology to deploy a Windows service application.

  • Know how to programmatically control a Windows service by passing control messages to it such as start, pause, continue and stop messages.