Debugging Service Applications
Go Up to Service Applications
You can debug service applications by attaching to the service application process when it is already running (that is, by starting the service first, and then attaching to the debugger). To attach to the service application process, choose Run > Attach To Process , and select the service application in the resulting dialog.
In some cases, this approach may fail, due to insufficient rights. If that happens, you can use the Service Control Manager to enable your service to work with the debugger:
To debug:
- First create a key called Image File Execution Options in the following registry location:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
- Create a subkey with the same name as your service (for example, MYSERV.EXE). To this subkey, add a value of type REG_SZ, named Debugger. Use the full path to bds.exe as the string value.
- In the Services control panel applet, select your service, click Startup and check Allow Service to Interact with Desktop.
For Windows NT:
On Windows NT systems, you can use another approach for debugging service applications. However, this approach can be tricky, because it requires short time intervals:
- First, launch the application in the debugger. Wait a few seconds until it has finished loading.
- Quickly start the service from the Control Panel or from the command line: start MyServ
You must launch the service quickly (within 15-30 seconds of application startup) because the application will terminate if no service is launched.