16 August 2012

How To Work Around "Specified Service Already Exists"

If you have ever created a Windows Service, you are likely familiar with the "specified service already exists" installation error message.  Most developers encounter this situation after making code changes, and attempting to install the updated service, for testing.  The problem is that Windows services can not be removed without a system reboot.

The solution is simple.  Install the service for testing, only once.  To test newly-compiled changes to the service:

  1. Stop the service
  2. Copy new files into the service installation directory, overwriting the old ones
  3. Start the service

Easy!

As always, use unit tests, to test code, instead of testing through execution.  There is little excuse to not test code, these days.  To expedite testing and TDD, I suggest installing NCrunch for Visual Studio (http://www.ncrunch.net/).

No comments:

Post a Comment

Please provide details, when posting technical comments. If you find an error in sample code or have found bad information/misinformation in a post, please e-mail me details, so I can make corrections as quickly as possible.