调试在ASP下运行的COM(Visual C++)

    技术2022-05-11  223

    调试在ASP下运行的COM(Visual C++): 工作环境:  win2000 , VC6.0 , IIS5.0 1.写一个调用com的 ASP 2.在asp文件中加上<% Response.Expires = 0 %>使得asp不会被 cache. 3.假定把asp放在Default Web Site(如c:/Inetpub/wwwroot/)下,在IIS 中选择Default Web Site 的属性,在Home Directory tab上,Application Protection:右边combox 选择Hign(Isolated)使得com运行在独立的进程中,click unload button让IIS unload你的com(If unload button is disabled, you need not click it) 4.把com 的action project configuration 设为Win32 Debug,并且Build 5.用IE浏览该asp,例如:http://127.0.0.1/testasp.asp 6.VC的tool->options, 在debug tab, enable Just-in-time debugging(checkbox) 7.打开windows task manager,在Processes tab可以看到多个dllhost.exe.因为你已经 浏览了该asp,其中一个dllhost.exe就是你的com的host. 找到这个host可以用 下面的方法(MSDN有正统方法介绍,但我没有用成功):在你的com中输出当前进程号{char buf[128]; sprintf(buf, "ISAPI running in process %d", GetCurrentProcessId()); OutputDebugString(buf);}以便调试(Attach to Process)。OutputDebugString的输出可以用dbgview.exe看到。 然后多按几次IE的refresh,看看哪个dllhost.exe使用了CPU,就是你要找的。 8.在windows task manager选中这个dllhost.exe,右健选择debug,会有一个 VC6.0程序打开并且attach到这个dllhost.exe进程,在这个VC的Project->Setting-> Debug tab->Category combox, 选择Additional DLLs,在下面的local name list中 加入你的com, 如c:/myproject/testcom/debug/testcom.dll (VC的debug 可以attach to process,但在win2000下不行,如果能够用vc attach 到 dllhost.exe,也可以直接attach) 9.在这个vc中打开你想设断点 的com的源文件,如c:/myproject/testcom/testcom.cpp 在这个文件中设断点 10.refresh你的IE, 你的断点会生效了!

    最新回复(0)