Debugging Recommendations

IOTA^_^    

Sams Teach Yourself ASP.NET in 21 Days, Second Edition
By Chris Payne
Table of Contents
Day 20.  Debugging ASP.NET Pages


ASP.NET provides a few different methods for debugging applications. So which should you use, and where?

If you're unsure of the location of the error, the best, and often easiest, method to use is tracing. Add Trace.Write and Trace.Warn throughout your code, and take note of which ones are executed and which aren't. Usually, this will lead you directly to the error, and from there you can handle it accordingly.

You should use try and catch whenever you're unsure of the code you've written, especially when you don't want users to see an error. Catch the error and handle it gracefully so users aren't caught by surprise.

Finally, use the CLR debugger when you want to follow the execution of your program in real-time. You can step through each line of code, watching variables to make sure they're assigned properly. This is a very powerful method of locating and correcting errors, but it can cause side effects such as loss of data and additional overhead. When you attach to a process (such as ASP.NET), all execution is frozen meaning it won't be able to function correctly which can cause problems for your application and users. You'll generally only want to use the CLR debugger when the other methods have failed in solving your problems.


    IOTA^_^    
    Top


    Sams Teach Yourself ASP. NET in 21 Days
    Sams Teach Yourself ASP.NET in 21 Days (2nd Edition)
    ISBN: 0672324458
    EAN: 2147483647
    Year: 2003
    Pages: 307
    Authors: Chris Payne

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net