Friday, October 18, 2013

[Windows Service Debugging] Separate code from service app for convenient debugging

Debugging a windows service is not as convenient as windows application as it states on this MSDN document.A simple way to improve debugging is to separate service function code from the service application to a DLL, and then create an normal windows application start the service object in DLL. Detailed steps as following:


  1. Create a windows service project that only has VS generated code in it.
  2. Create a DLL proeject that contains the service object.
  3. Let service project call the service object to start it.Then your service would work. But this is not for debugging.
  4. Create a normal windows application, and just as the service project, just call the service object ans start it. This application is convenient for you to debug the service object.