Debugging Tools for Windows

Debugging the Service Application Automatically

A debugger can be launched automatically when the service application starts up. Alternatively, it can be launched automatically when the service application encounters an exception or executes a DebugBreak command. If you have chosen one of these methods, this topic explains how to proceed. If you are not sure which method to choose, see Choosing the Best Method.

Then use the following procedure:

  1. Do one of the following preparatory steps:
  2. If the service is already running, you must restart it for these changes to take effect. We recommend that you restart Windows itself, in order to remove any effects of the running service. If you do not want to restart Windows, use the following commands, where ServiceName is the name of the service:

    net stop ServiceName 
    net start ServiceName 

  3. If you have chosen to debug the service application's initialization code, when the the service starts, the debugger is launched and attaches to the service application.

    If you have chosen to let the debugger be triggered by an exception, the service application executes normally until it encounters an exception or executes a DebugBreak function. At this point, the debugger is launched and attaches to the service application.

  4. The next step depends on the debugger command line you specified during step 1:
  5. When the debugger starts, the service pauses at the initial process breakpoint, the exception, or the DebugBreak command. This enables you to examine the current state of the service application, set breakpoints, and make any other desired configuration choices.
  6. Use g (Go) or another execution command to resume the execution of the service application. For other available commands, see Debugger Operation (User Mode) and Debugger Operation (User Mode).

Additional Information

For information on the DebugBreak function, see  DebugBreak in the Microsoft Windows SDK.

Build machine: CAPEBUILD