RAD Studio
ContentsIndex
PreviousUpNext
Debugging 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 RunAttach 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:

  1. First create a key called Image File Execution Options in the following registry location:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion

  1. 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.
  2. In the Services control panel applet, select your service, click Startup and check Allow Service to Interact with Desktop.
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:

For Windows NT:

  1. First, launch the application in the debugger. Wait a few seconds until it has finished loading.
  2. 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.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!