1 / 15

Debugging and tracing in .NET

Debugging and tracing in .NET. Presented by: Beeninder Dhanjal Department of Computer Science. What can be debugged?. Windows Forms Web Forms Web services Stored Procedures. Debugging elements. Project modes Breakpoints Command Window Call stack window Modules window Watch window

nyoko
Download Presentation

Debugging and tracing in .NET

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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. EnterpriseDebugging – 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(Interest>0) • Shows the Complete Call Stack on Debugging.

  10. TraceSwitch Class • Open Application.config file • Between the <switches> tags enter this line of XML: <add name="mySwitch" value="2"></add> 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 <?xml version="1.0" encoding="utf-8" ?> <configuration> <system.diagnostics> <switches> <add name="mySwitch" value="2"></add> </switches> </system.diagnostics> </configuration>

  12. Tracing in ASP.NET • Open the Web.Config file and replace Trace=“false” to Trace=“True” • 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 - <authorization> and change: <deny users=”?” /> to <allow users=”none” /> • 9. From the main menu, select Debug | Start without debugging

  15. Thank you!

More Related