LANGUAGES: All .NET languages
ASP.NET VERSIONS: 1.0 | 1.1
Debug .NET Apps ... Without VS .NET
Use DbgCLR.exe to root out bugs in your Web services and ASP.NET apps.
By Jeff Prosise
Everyone knows you can debug ASP.NET projects built with Visual Studio .NET using VS .NET's fabulous integrated debugger. But did you know you also can use a full featured debugger to debug ASP.NET apps and Web services built using something other than VS .NET? It's named DbgCLR.exe and it comes with the .NET Framework SDK. It's great for debugging .aspx and .asmx files that contain embedded code (as opposed to files that use code behind). Here's how you can put DbgCLR to work using breakpoints to debug an .aspx file.
First enable debugging in the page you want to debug. You can enable debugging for a particular page by adding a Debug="true" attribute to the @ Page directive at the top of the page, or you can enable debugging for the entire application by adding a <compilation debug="true"> element to web.config. Next, open the page you wish to debug in your browser and start DbgCLR (you can find it in the Program Files\Microsoft Visual Studio .NET\FrameworkSDK\GuiDebug directory). Now select the Debug Processes command from DbgCLR's Tools menu. Select the ASP.NET worker process in the ensuing dialog (the process name is either aspnet_wp.exe or w3wp.exe, depending on which version of IIS you're running), click on the Attach button, and then click on Close. Next, use DbgCLR's File/Open command to open the .aspx file you intend to debug and set your breakpoints. Finally, return to your browser and do something to cause a breakpoint to be hit. Once the breakpoint is reached, DbgCLR moves to the foreground and highlights the statement where execution was halted. Press F10 to single-step your way through the code, or you can use DbgCLR's myriad other debugging features to analyze the offending code.
Now that you know about DbgCLR, you can run any ASP.NET app in a debugger regardless of whether the app was developed with Visual Studio .NET.
Jeff Prosise is author of several books, including Programming Microsoft .NET (Microsoft Press). He also is a co-founder of Wintellect (http://www.wintellect.com), a software consulting and education firm that specializes in .NET. Contact Jeff at [email protected].