45.3. Debugging Running Applications

Sometimes you'll need to debug an application that is running outside Visual Studio. There are many reasons why you would want to do this, such as if a defect appears only when an application is executed in production. Fortunately, Visual Studio provides a simple method for attaching and debugging a Windows executable or web application that is actively running.

45.3.1. Attaching to a Windows Process

Attaching to a running Windows process is a fairly straightforward task in Visual Studio. Ideally, you will have the original source code open in Visual Studio, in which case you will be able to debug the process as if you had launched it in debug mode from Visual Studio.

If you are debugging an executable without access to the source code, the available debugging features are limited. If the executable was built without debug information or symbols, available features are further limited and it is unlikely that you will gain much useful information by debugging it in this way.

From the Debug menu, use the Attach to Process command. This displays the Attach to Process dialog window (see Figure 45-5) from which you can browse all active processes. Locate the application that you wish to debug from the Available Processes list and click the Attach button.

Figure 45.5. Figure 45-5

Because attaching to an application requires these manual steps, ...

Get Professional Visual Studio® 2008 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.