visual studio attaching to a process in debug mode

2019-07-31 09:22发布

i have a strange problem.

the dll that i built (lets call it my.dll) in c++ visual studio 2010 uses a third party library (say tp.lib) which in turn calls a third party dll (say tp.dll).

for debugging prupose i have in configurationProperties->debugging->command: Excel.exe and configurationProperties->debugging->commandArguments: "$(TargetPath)"

in my computer i also set PATH variable to the directory where tp.dll resides

now when i hit the F5 in visual studio excel opens up with my.dll and crashes giving me a "cannot open in dos mode" error. the reason this happens is tp.dll is not deployed when debug version of my.dll is deployed.

when i open an instance of excel seperately and manually drop the debug version of my.dll then everything works fine and i can see all my functions that i wrote in my.dll

the only issue is now i do not know how to debug becuase i do not know how to attach visual studio to the instance of excel i opened up seperately.

my question is:

1> how can i attach visual studio to an already opened instance of Excel

or

2> how can i hit F5 and still make Excel pick up the required tp.dll from the directory specified in the PATH variable before it starts to deploy my.dll.

any of these two will allow my to step through the code for the purpose of debugging.

thanks in advance.

2条回答
爷的心禁止访问
2楼-- · 2019-07-31 10:00

okay i figured out a way to do it by trial and error 1>build the debug dll. 2> open instance of excel and drop my.dll from the debug folder to it. 3> in visual studio 2010 : properties->configurationproperties->debugging->command = excel.exe 4>properties->configurationproperties->debugging->Attach = yes

and now you hit F5 in visual studio. this will attach the visual studio editor to the running copy of my.dll which will allow to to step through the code.

查看更多
男人必须洒脱
3楼-- · 2019-07-31 10:00
  1. Unless you are using the Express edition you can attach visual studio to a running process.
  2. I would copy tp.dll into the folder containing my.dll.
查看更多
登录 后发表回答