Howto: Debug COM+ components written in Delphi under Windows 2000 and Windows XP

As the issue (read: problems) of debugging COM+ components in Delphi has
caused me to waste a lot of time, I hereby provide a cook book on how I
manage to debug COM+ components. The procedure have been tested on Delphi 5
and Windows 2000 (no service pack, sp1 and sp2) and the final build (2600)
of Windows XP.

Windows 2000:
Verify that integrated debugging is on (Tools / De{*word*81} Options).
Verify that COM cross process support is off (Tools / De{*word*81} Options /
Distributed Debugging).
Switch debugging on in Project / Options / Linker. "Include TD32..." and
"Include remote..." must be checked.
Build the project
Install the component under COM+ (Component Services).
Right-click the package in the Component Services explorer and select
properties.
On the identity tab, make sure the identity the package runs under is
"Interactive User"
Copy the Application ID GUID on the package from the General tab.
Back in Delphi, Select Run / Parameters. Set the host application to
%windir%\system32\dllhost.exe and the parameters to
/ProcessID:{93961260-8BD5-43FC-AE36-849654F70E43} (replace the GUID with
your application ID).
To verify that you are able to load the server properly, open the Event Log
window (View / Debug Windows / Event log)
Set desired breakpoints and start the server (Run).
Run your client such as ASP pages or test client and watch your server
breakpoints hit.

Windows XP:
Same as above, except that in order to have the debug info load for your
COM+ server, the "active" path in Delphi must be the directory where your
COM+ DLL resides (!). The easiest way to accomplish this I have so far found
to:

1. Copy %windir%\system32\dllhost.exe to the same location where the COM+
server DLL resides
2. Open Run / Parameters
3. Select Browse for the host application
4. Select the dllhost.exe you just copied.

If in a later debug session breakpoints do not longer hit, repeat the steps
2-4. I would be happy to receive directions on a better way of doing this!

Ole Wiig
Netaccount AS - www.netaccount.com