Debugging ASP.NET without Visual Studio using DbgCLR
Visual Studio is great, but not everyone can afford it, especially hobbyists althought this is likely to change soon with the new Express versions of Visual Studio 2005. Anyway, at the moment its expensive! There is nothing to stop you creating ASP.NET pages just using something like notepad, but when it comes to debugging your code it can be a real pain - there is only so far that using the Trace.Write() and Response.Write() methods can take you!However there is a solution! Microsoft distribute a .NET SDK which contains what appears to be more or less the complete Debugging part of Visual Studio as a stand-alone application called DbgCLR.exe. If you've not got the .NET SDK yet, you can download it from here. Where DbgCLR.exe gets installed to depends on if you have Visual Studio installed or not - here are some examples based on my workstation and server
- Visual Studio installed: C:>Program FilesMicrosoft Visual Studio .NET 2003SDKv1.1GuiDebug
- Visual Studio not installed: C:>Program FilesMicrosoft.NETSDKv1.1GuiDebug
- - Make sure you ASP.NET application is on the server and configured correctly and otherwise running fine (except the bits you are looking to debug obviously).
- - If you haven't already, put the following into your application's web.config file, within the system.web section:
<configuration>
<compilation debug="true"/>
</configuration> - - Start up DbgCLR.exe
- - From the File menu, go to Open and then File and load in the file you'd like to debug. Don't worry if you want to step through code in several different files (e.g. if your code calls a class in a separate file) - DbgCLR will load those up automatically as they are needed.
- - Find the line in the code where you'd like to set the breakpoint/s (i.e. the point at which normal execution of the application pauses and waits for you to debug it). You can do this by either pressing F9, or clicking on the grey left-hand margin. A breakpoint appears as a brown dot in the margin when its set.
- - Ok now to chose what process to attach to. This will vary depending on what you are using for your server:
- - Windows 2000: aspnet_wp.exe
- - Windows 2003: w3wp.exe
- - WebMatrix's server: webserver.exe
- - Ok, if you've managed to attach to the server process you should now see the familiar play, pause and stop buttons on the DbgCLR's tool bars - the play button should be shaded out as the process is currently running as normal.
- - Now you're ready to begin debugging - simply go to the page where the code you set a breakpoint for will be called and DbgCLR should stop at the break point, allowing you to step through the code as normal.
- - When you are done debugging, just press the Stop icon on the tool bar to unattatch the debugger from the server process.
Back
23.02.2006.
Great!
Lucio
10.08.2006
Awesome, thanks for this!