Debugging COM+ in Delphi7
Collected and compiled by Liu Xiaoming (Cipher)
The most troublesome issue in developing COM+ application systems is how to debug COM+ components. Since COM+ is executed in the COM+ execution environment, Delphi programmers cannot directly set breakpoints on the application server for debugging in Delphi's IDE like Delphi's distributed multi-tier application system.
In fact, Delphi can still debug COM+ components in Delphi's integrated development environment, or allow programmers to set breakpoints in the program unit of the COM+ component in the integrated development environment, and then execute the client application to call the COM+ component. At this time, Delphi will bring execution control to Delphi's integrated development environment and pause at the breakpoint set by the programmer to allow the programmer to start debugging. From now on, programmers can debug COM+ components just like debugging normal applications. However, to debug COM+ components in this way, programmers must first make some settings.
1. Activate the COM+ component project to be debugged in Delphi's integrated development environment, click the PRojects|Options menu, select the Linker page in the pop-up dialog box, and select include Td32 info and include remote debug symbol;
2. Click the Run|Install Com+ Objects menu to register the COM+ component, preferably to a new application or to an existing application (this application needs to be generated by Delphi's registered COM program).
3. Run Win2000 Control Panel | Administrative Tools | Component Services, find the COM registered application in the COM+ application, right-click, select the "Properties" menu, in the pop-up dialog box, select the "Advanced" page, and select The "Start in debugger" option will have something similar to the following in the debugging path below: "C:/Program Files/Borland/Delphi7/Bin/bordbg70.exe" dllhost.exe /ProcessID:{9CEC476D-83A5-4C2B-AFF1-3E83A147B866}
4. Return to Delphi's integrated development environment, click the Run|Parameters menu, and in the dialog box, set Hostapplication to: C:/WINNT/system32/DLLHOST.EXE (this should be set according to your operating system installation situation). Parameters is set to: /ProcessID:{9CEC476D-83A5-4C2B-AFF1-3E83A147B866}; the value of this GUID must be consistent with the attribute value in the Win2000 component service, and can be copied directly from there.
5. Set breakpoints and run COM in Delphi's integrated development environment;
6. Run the client program that calls this COM in Windows (or in the newly opened Delphi environment).
At this time, you will find that the COM in the Delphi development environment stops at the breakpoint, and you can proceed with single-step tracking and debugging.