简体   繁体   中英

Dynamic debugging with visual studio

Hi I have two EXEs( EXE1 and EXE2 ). In that EXE1 will run EXE2 at a specific interval. I need to debug EXE2 while it is running. How can I debug EXE2 by attaching it with visual studio?

You can set registry settings to start debugging immediately after your second exe starts. Here is how to do on msdn: https://msdn.microsoft.com/en-us/library/a329t4ed(v=vs.90).aspx

Open project with EXE2 code in Visual Studio. Once executable is started, attach to it's process from Visual Studio:

Debug -> Attach to process

Check 'Show processes from all users' (just in case). Find appropriate process by name and attach to it. That's it.

Hi this can be achieved by placing the following code

System.Diagnostics.Debugger.Launch()

before the code to debug of corresponding EXEs . When that EXE executed not under a debugger, a dialog will come up asking if you want to launch the debugger. Choose VS as your JIT (Just In Time) debugger and VS will start and you can single step or inspect your program's execution at that line.

Be sure to remove any debug lines before deploying your program!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM