问题
I have an old C++ COM component which has to stay in Visual Studio 6.0 format. I can't for the life of me figure out how to debug the code in the actual COM component.
I'm able to build it in debug mode, add breakpoints and attach it to the dllhost.exe process, but the Visual Studio environment will only show me the disassembly from dllhost.exe and not my source code (It also doesn't stop on the breakpoints).
I remember a while ago there was a way to make IIS (or inetinfo.exe) the target of your debug action (i.e. when Visual Studio 6.0 asks you for the executable to launch your dll) and IIS would run in a single process mode. There was a registry key you needed to change, but googling hasn't helped.
回答1:
If it is a VB6 based COM component, you can open the project in VB6 and run it (a DLL project cannot be run). The project properties has some option whereby it can be asked to run so that it runs & registers itself.
Now, try hitting the ASP page, which makes a call to COM component. The breakpoints set in the class files will be hit, as the calls are made from ASP page.
回答2:
First of all, PDB file (produced during the compilation) should be in the same directory with DLL (can be set in project properties).
If your object does not use some ASP-specific functionality (Request, Response, Session objects) you can copy its invocation code to .vbs file and debug via setting cscript.exe your.vbs as debug target program.
There are explanations (for example) how to debug ISAPI DLLs - they are applicable to your COM object too (from OS/debugger point of view both are DLLs loaded into IIS process). Put attention to your IIS version and in/out-of-process stuff.
And finally, if nothing other helps, you can add some logging via OutputDebugString function and see it in free DebugView program.
来源:https://stackoverflow.com/questions/370250/how-to-debug-com-object-in-visual-studio-6-0-that-is-created-in-an-asp-page