I read the MSDN article on the topic. To quote:
Because a service must be run from within the context of the Services Control Manager rather than
I stole this from C. Lawrence Wenham, so I can't really take credit, but you can programmatically attach a debugger to a service, WITHOUT breaking execution at that point, with the following code:
System.Diagnostics.Debugger.Launch();
Put this in your service's OnStart() method, as the first line, and it will prompt you to choose an instance of VS to attach its debugger. From there, the system will stop at breakpoints you set, and on exceptions thrown out. I would put an #if DEBUG
clause around the code so a Release build won't include it; or you can just strip it out after you find the problem.