
Debug a Running Process #41
Chapter 5, Debugging
|
161
HACK
HACK
#41
Debug a Running Process Hack #41
Avoid having to re-create bugs by attaching directly to a process that you
started outside of the IDE’s control.
Have you ever found yourself 20 minutes into a test session when you find
that you have finally reproduced that bug that people have been complain-
ing about for months? But you’re not running in the debugger, so you’ll
never figure out how you got the application in this state. By attaching to the
process directly without running your project, you can examine memory,
look at the call stack, and work out the bug—all without losing the state of
your application.
Attaching to a Process
In order to attach to a running process, you first need to load the project you
want to debug. For a Windows Forms application or a service, simply select
the Debug
➝ Process menu item (for ASP.NET applications, see the next
section). Then select the process you wish to debug from the Processes dia-
log shown in Figure 5-26. After selecting the process, click Attach.
You are then prompted to determine which types of code you wish to debug
in the Attach to Process dialog, which is shown in Figure 5-27.
Figure 5-26. Process dialog