Reputation: 1791
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?
Upvotes: 3
Views: 933
Reputation: 1791
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!
Upvotes: 1
Reputation: 1955
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.
Upvotes: 1
Reputation: 1047
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
Upvotes: 3