Monday, June 13, 2011

Creating Windows Services, visually (well using the Component Designer and Visual Studio Windows Service template anyway)

Nikhil Singhal's Blog - How to create a Windows Service in the Component

"Microsoft Windows services enable you to create long-running executable applications that run in their own Windows sessions. These services can be automatically started when the computer boots, can be paused and restarted, and do not show any user interface. These features make services ideal for use on a server or whenever you need long-running functionality that does not interfere with other users who are working on the same computer.

You create your service as a Microsoft Visual Studio project, defining code within it that controls what commands can be sent to the service and what actions should be taken when those commands are received. Commands that can be sent to a service include starting, pausing, resuming, and stopping the service; you can also execute custom commands.

After you create and build the application, you can install it by running the command-line utility InstallUtil.exe and passing the path to the service's executable file, or by using Visual Studio's deployment features. You can then use the Services Control Manager to start, stop, pause, resume, and configure your service.

A Windows Service can either be created using the Visual Studio project template called Windows Service OR you can write your own services by setting up the inheritance and other infrastructure elements yourself. In this post we will focus on creating a service using the provided template and component designer. We will explore the advanced method of coding the service directly in a later post.

Creating a Windows Service using the Component Designer

When you create a service, you can use a Visual Studio project template called Windows Service. This template automatically does much of the work for you by referencing the appropriate classes and namespaces, setting up the inheritance from the base class for services, and overriding several of the methods you're likely to want to override. To create a service using the component designer, you need to follow 3 basic steps:



Been a long time since I've seen an end-to-end Creating a Windows Service tutorial like this. Most of us don't create services often, so a review like this can come in handy...

No comments: