Home > Articles > Programming > Windows Programming

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Attaching to Processes

At some point you might need to attach to a process running somewhere on the computer and debug it from within the ASP.NET page. This could be the ASP.NET process, aspnet_wp.exe, or another running service, or any other program running on the server. This can be accomplished quite easily.

Under the Debug menu you will find the Processes selection. Clicking this brings up the dialog box in Figure 7.6.

Figure 7.6 Attaching to a running process.

By default, you will see only the processes that you have started in some way. If you click the Show System Processes check box, you have access to everything that is running on the current machine. Click the process to be debugged, and then click the Attach button. Now, if that process hits a breakpoint or any other type of debugger event, that event pops up in the Visual Studio .NET IDE. You can also force the program to break by clicking the Break button at the bottom of the window. At any time, you can stop debugging the process by clicking the Detach button. Terminate kills the process altogether.

After clicking the Attach button, you are given a choice of what type of debugging you want to do on the process you've selected. Figure 7.7 shows an example of this dialog box.

Figure 7.7 Choosing the debug type.

If you are attaching to a .NET process written using the Common Language Runtime (CLR), choose the Common Language Runtime option from the dialog box. If you'll be breaking into a process that uses Microsoft Transact SQL language, check Microsoft T-SQL as your debug type. Native enables you to debug a standard Win32 application. This enables you to debug a Win32 program at an assembly language level. Finally, the Script type gives you the capability to debug standard Visual BasicScript and JavaScript. This is especially useful for debugging an instance of Internet Explorer.

  • + Share This
  • 🔖 Save To Your Account