This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!
Attaching To a Running Program or Multiple Programs
With the Visual Studio debugger has the ability to attach to a program that is already running outside of Visual Studio. You can use this attach capability:
- To debug a program that was not created in Visual Studio.
- To debug multiple programs simultaneously.
- To debug a program a running on a remote machine.
- To start the Visual Studio debugger automatically when a program crashes while running outside of Visual Studio (just-in-time debugging).
Once you have attached to a program, you can use debugger execution commands, inspect the program state, and so on. You ability to inspect the program may be limited, of course, depending on whether the program was built with debug information and whether you have access to the program's source code.
To attach to a running program
- From the Debug menu, choose Programs.
- In the Programs dialog box, find the program you want to attach to from the Available Processes list. If the program you want to debug is running on another machine, you must first select the remote machine.
- Click the Attach button.
- In the Attach to Process dialog box, make sure the appropriate program type (for example, Win32 or NGWS runtime) is selected in Choose program types to be attached now and in the future.
- Click OK.
- At the bottom of the Programs dialog box is a dropdown list labeled When debugging is stopped. Choose the behavior you want to occur when you stop debugging the selected program. In most cases, it is okay to terminate the program when debugging stops, but you may want to keep it running (for example, so that you can attach to it again in the future.) If you attach to a system process, be especially careful. Terminating a system process can have sudden and undesirable effects, including crashing the system. If you don't want the program to terminate when the debugging session ends, choose Detach from this process rather than Terminate this process.
- Click OK.
The Available processes list is displayed automatically when you open the Programs dialog box. Processes can start and stop in the background while the dialog box is open, however, so the contents may not always be current. You can refresh the list at any time to see the current list of processes.
To refresh the Programs list
- Click on the Refresh button.
You can be attached to multiple programs when you are debugging, but only one program is active in the debugger at any given time. You can set the active program in the Programs dialog box.
All Debug menu execution commands affect the active program. If you choose Break from the Debug menu, the debugger breaks the active program. You can break any debugged program, active or inactive, from the Programs dialog box.
To break a debugged program
- In the Programs dialog box, locate the process you want to break to in the Debugged Programs list.
- Click the Break button.
When are finished debugging an attached program, you can detach from the program.
See Also
Using the Debugger