Wednesday, October 04, 2006

Two Handy Tips for Coding Windows Services

I've been doing some development on Windows Services the last couple days and found two handy bits of info.

First, always make sure to close the Services management console when you're installing or deinstalling services.  The Services console can keep a handle open on various parts of the registry, causing you grief when your service is being removed.  An attempt to install a new version of the service will give you an error "The specified service has been marked for deletion."

Secondly, if you're working with multiple services in a single executable make sure to add each to the list of services to start:

ServicesToRun = new ServiceBase[] { new NormalMessageService(), new EmergencyMessageService() };

(Sorry about bad formatting -- CopySourceAsHtml 2.0 is giving me some grief today.  I'll get it noodled out.)

1 comment:

Anonymous said...

Depending on where you're at in the development cycle of your service, I've found this [0] to be useful, and prevents the hassle of having to deal with the windows service control monitor altogether.

[0]: http://shrinkster.com/ivd

Subscribe (RSS)

The Leadership Journey