DebuggableSelfInstallingService

A Debuggable, Self-Installing Windows Service Template based on James Michael Hare's excellent blogposts

18
8
C#

Debuggable, Self-Installing, Windows Service

A Debuggable, Self-Installing Windows Service Template based on James Michael Hare’s excellent blogposts:

How to use

  • Download the Visual Studio template
  • Create a new project and select / search for DebuggableService (see screenshot below)
  • Implement any of the provided OnStart(), OnStop(), OnPause(), OnContinue(), OnShutDown() and OnCustomCommand() methods
  • Run/debug your application as usual, continue your development cycle as always
  • When your application is done, open a console (with Administrative privileges!) and execute MyApp.exe -installto install your service; now you can start/stop/pause your service. To uninstall your service simply run MyApp.exe -uninstall.

Screenshot of project template selector

More

The WindowsService.cs file contains the ServiceImplementation class which, as it’s name suggests, implements all service methods. This class has been fitted with an WindowsServiceAttribute which you can use to control some service-specific properties like Name, DisplayName, Description, UserName, Password, EventLogSource, StartMode, CanPauseAndContinue, CanShutdown, CanStop and services your service depends on via ServiceDependsOn.

But I want more!

Sure! No problem. I can recommend the excellent Topshelf project, also available as NuGet package. This allows for even more control, has way better documentation and is also available on GitHub!

Project status

Works (tested) with:

  • Visual Studio 2013
  • Visual Studio 2015
  • Visual Studio 2017
  • Visual Studio 2019

Project status