Debugging and tracing in .NET - PowerPoint PPT Presentation

About This Presentation
Title:

Debugging and tracing in .NET

Description:

Lightweight Debugger(DBGCRL.exe) Conditional breakpoints. Click the breakpoints ... In the Processes dialog box, check Show System Processes if it is unchecked ... – PowerPoint PPT presentation

Number of Views:384
Avg rating:3.0/5.0
Slides: 16
Provided by: Bin55
Learn more at: https://www.cs.odu.edu
Category:

less

Transcript and Presenter's Notes

Title: Debugging and tracing in .NET


1
Debugging and tracing in .NET
  • Presented by
  • Beeninder Dhanjal
  • Department of Computer Science

2
What can be debugged?
  • Windows Forms
  • Web Forms
  • Web services
  • Stored Procedures

3
Debugging elements
  • Project modes
  • Breakpoints
  • Command Window
  • Call stack window
  • Modules window
  • Watch window
  • Enterprise Debugging (Remote)
  • Lightweight Debugger(DBGCRL.exe)

4
Conditional breakpoints
  • Click the breakpoints window icon.
  • Go to the breakpoints pane and right-click this
    breakpoint, and select Properties.
  • On the File tab, click the condition button.
  • In the breakpoint condition dialog, in the
    condition field, enter condition like
    sometextbox.Text 29 or you can reset the Hit
    Counter.

5
Debugging window
  • Select the View Other Windows Command Window
    from the main menu.
  • Example
  • In the Command Window, enter for Example ?
    OrderID, and press Enter. This evaluates the
    value of OrderID.
  • Can view data adapter values.
  • Predefined commands

6
Enterprise Debugging Attaching to Processes
  • Run the application through the URL
  • In VS. Net select Tools, Debug Process.
  • In the Processes dialog box, check Show System
    Processes if it is unchecked
  • Select the aspnet_wp.exe (or w3wp.exe) process,
    and then click the Attach button which will open
    the Attach to Process window.
  • Set break points and debug.

7
Stored Procedure Debugging
  • Enable the SQL Debugging option by Right Clicking
    the Solution explorer properties Configuration
    option Debugging.
  • Open Server Explorer, Browse to the database and
    Right click on the desired Store Procedure.
  • Click Edit Stored Procedure.
  • Place breakpoints and start Debugging.

8
Debugging Windows Forms
  • Using Debug.Writeline()
  • Using Trace
  • Example
  • -- Dim tfl As New
  • TextWriterTraceListener("C\TraceLog.txt")
  • -- Trace.Listeners.Add(tfl)
  • -- Trace.WriteLine(Trace.Listeners.Count() "
    trace listeners")

9
Assersion
  • Gives 3 options when the condition is met.
  • Abort
  • Retry
  • Ignore
  • Example
  • Trace.Assert(Interestgt0)
  • Shows the Complete Call Stack on Debugging.

10
TraceSwitch Class
  • Open Application.config file
  • Between the ltswitchesgt tags enter this line of
    XML
  • ltadd name"mySwitch" value"2"gtlt/addgt
  • Where
  • 1 Only Error Messages
  • 2 Error and Warning Messages
  • 3 Informational, Warning and Error Messages.
  • 4 Verbose, Informational, Warning, and Error
    messages.

11
Application.Config
  • lt?xml version"1.0" encoding"utf-8" ?gt
  • ltconfigurationgt
  • ltsystem.diagnosticsgt
  • ltswitchesgt
  • ltadd name"mySwitch" value"2"gtlt/addgt
  • lt/switchesgt
  • lt/system.diagnosticsgt
  • lt/configurationgt

12
Tracing in ASP.NET
  • Open the Web.Config file and replace
    Tracefalse to TraceTrue
  • Run the application and replace the start page in
    the IE with trace.axd
  • Example
  • http//localhost/Homework3/trace.axd
  • Can be done for individual files.

13
Tracing a Web Service
  • 1. In Solution Explorer, right-click the web
    service .asmx, click View Code
  • 2. uncomment Context.Trace.Write
  • 3. From the main menu, select Debug Start
    without debugging
  • 4. Start Microsoft Internet Explorer and enter
    http//localhost/HomeWork3/trace.axd to open the
    Request Details page.
  • 5. Click View Details.

14
Continued.
  • 6. Scroll to Trace Information, double click
    WebService
  • 7. Close Microsoft Internet Explorer.
  • 8. In Solutions Explorer, double click web.config
    - ltauthorizationgt and change
  • ltdeny users? /gt
  • to
  • ltallow usersnone /gt
  • 9. From the main menu, select Debug Start
    without debugging

15
  • Thank you!
Write a Comment
User Comments (0)
About PowerShow.com