Presentation is loading. Please wait.

Presentation is loading. Please wait.

DEV339 Best Practices for Debugging Visual Studio.NET Applications Keith Pleas Architect, Guided Design

Similar presentations


Presentation on theme: "DEV339 Best Practices for Debugging Visual Studio.NET Applications Keith Pleas Architect, Guided Design"— Presentation transcript:

1 DEV339 Best Practices for Debugging Visual Studio.NET Applications Keith Pleas Architect, Guided Design keithp@guideddesign.com

2 2 Overview About debugging What's new in Visual Studio.NET 2003 Debugging in Visual Studio.NET Client applications Web applications SQL Server database objects Tracing Additional Debuggers

3 3 Types of “Bugs” Inconsistent User Interfaces Un-met expectations Poor performance Crashes Data corruption

4 4 Debugging: A Methodology by John Robbins, Wintellect Duplicate the bug Describe the bug Always assume that the bug is yours Divide and Conquer Think creatively Leverage tools Start heavy debugging Verify that the bug is fixed Learn and share

5 5 Debugging Process Tracking & catagorization Version control Change control Daily builds Unit tests Smoke tests

6 6 Visual Studio.NET Errors Errors versus Warnings For VB, on for manual compiles by default Listed for C#, grovel for VB Attributes DebuggerStepThroughAttrribute Opposite of what you’d think You _can_ set breakpoints DebuggerHiddenAttribute

7 7 Visual Studio.NET 2003 What’s New in the Debugger Viewing C# unhandled exceptions Better collection display in the debugger (ArrayList, HashTable) Alphabetically sorted view of members IntelliSense in the Immediate window Filtered Call Stack view

8 8 Visual Studio.NET 2003 What’s New in the Debugger Reload symbols from the Call Stack window Automatic stepping into Web Services Symbol server support Debugging managed dumps using Son of Strike (SOS.dll) NTSD extension

9 9 Cool Tip Debugging a DataSet made easier! Question: How do you debug a DataSet today? REPEAT Click, Expand, Scroll UNTIL ( Index Finger Becomes Sore ) Hard to determine what you’re looking at Hint: Use the Immediate window to make life a little easier

10 10 Debugging.NET EXEs Two ways to debug a.NET EXE Start (F5) Manually attach to the EXE using the Processes dialog In addition, you can customize F5 to: Debug an application remotely Debug an URL instead of your project Debug another program instead of your project

11 11 Customizing demo demo

12 12 Cool Tip Expand your types automatically! Text file in Common7\Packages\Debugger directory mcee_cs.dat for C# mcee_mc.dat for MC++ Allows immediate display of custom types in Watch, QuickWatch, DataTips, etc. See actual file for documentation Must restart VS

13 13 Debugging.NET DLLs Cannot debug DLLs directly Two ways to debug a DLL 1. Specify host process in project properties 2. Manually attach

14 14 Debugging a DLL demo demo

15 15 Debugging XML Web Services You can debug an XML Web Service: On its own Called from a ASP.NET Web Form Called from a client application That is already running

16 16 Debugging XML Web Services demo demo

17 17 SQL Server Debugging Two ways 1. Use Server Explorer Debug stored procedures and functions 2. Call procedure from application Set breakpoint Enable SQL debugging

18 18 Debugging SQL Stored Procedures demo demo

19 19 JIT debugging “Just In Time” (JIT) Debugging Allows you to debug crashes (exceptions) when application is not running under the debugger Default is off for Windows Forms Can select which debugger to attach with <configuration> </configuration>

20 20 Testing Your ASP.NET Application Using Different Browsers VS always uses IE when debugging an ASP.NET application What if you want to debug using other browsers?

21 21 Testing ASP.NET Web Forms demo demo

22 22 Remote Debugging ASP.NET 1.Setup debug components on remote machine Local Machine Remote machine Remote Debugging 2. Add user to Debugger Users group 3. Typically user needs to be admin

23 23 “Troubleshooting: How do I debug an ASP.NET app on my machine?” Troubleshooting F5 Turn debugging on in web.config file Make sure ASP.NET debugging is turned on in your project properties When aspnet_wp.exe runs as SYSTEM, the user debugging it must be an administrator. Your web application must use Integrated Windows Authentication.

24 24 Client Instrumentation (1) System.Diagnostics Instrumentation support Debug class Trace class Use Debug during development Use Trace in deployed apps

25 25 Client Instrumentation (2) Conditionally compiled methods Define these constants via: Project settings Command line In code

26 26 Client Instrumentation (3) Use switch in code Change Application configuration file: Enables switch Sets trace level static BooleanSwitch switch = new BooleanSwitch(“TraceSample”, “Tracer”);…Trace.WriteLineIf(switch.Enabled, “Trace is running”)

27 27 Client Instrumentation (4) Trace Listeners Receive trace messages Three predefined listeners DefaultTraceListener EventLogTraceListener TextWriterTraceListener

28 28 Tracing in Windows Applications demo demo

29 29 Tracing ASP.NET Use the Trace property Trace.Warn Trace.Write Two types: Page level trace Application tracing Web.config change Read Trace.axd

30 30 Tracing in ASP.NET demo demo

31 31 Additional Debuggers GUI Debugger Console Debugger Deployment considerations

32 32 Summary Debugging client applications Debugging Web applications Debugging SQL Server Tracing

33 33 Ask The Experts Get Your Questions Answered 13:00 to 15:00 Thursday 3 July

34 34 Community Resources http://www.microsoft.com/communities/default.mspx Most Valuable Professional (MVP) http://www.mvp.support.microsoft.com/ Newsgroups Converse online with Microsoft Newsgroups, including Worldwide http://www.microsoft.com/communities/newsgroups/default.mspx User Groups Meet and learn with your peers http://www.microsoft.com/communities/usergroups/default.mspx

35 35 Suggested Reading And Resources The tools you need to put technology to work! TITLEAvailable Today Debugging Applications for Microsoft®.NET and Microsoft Windows®: 0-7356-1536-5 Microsoft Press books are 20% off at the TechEd Bookstore Also buy any TWO Microsoft Press books and get a FREE T-Shirt

36 36 evaluations evaluations

37 37 © 2003 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS SUMMARY.


Download ppt "DEV339 Best Practices for Debugging Visual Studio.NET Applications Keith Pleas Architect, Guided Design"

Similar presentations


Ads by Google