DEV450 Visual Studio: Best Practices For Debugging Managed Applications Habib Heydarian Scott Nonnenberg Program Managers Microsoft Corporation.

Download Report

Transcript DEV450 Visual Studio: Best Practices For Debugging Managed Applications Habib Heydarian Scott Nonnenberg Program Managers Microsoft Corporation.

DEV450
Visual Studio:
Best Practices For Debugging
Managed Applications
Habib Heydarian
Scott Nonnenberg
Program Managers
Microsoft Corporation
Overview
Setting up for debugging
Environment
Symbol server
JIT debugging
ASP.NET Debugging
Web Applications
Web Services
Debugging SQL Server
Instrumentation and Tracing
Setting Up For Debugging
Generate a debug build
Generates debugging info (pdb file)
F5 or attach
Customize F5
Remote launch
Launch URL
Launch executable
Launch debuggers
Remote Debugger Setup
Remote Debugging
Local Machine
1.
2.
3.
Remote Machine
Setup debug components on remote machine
Add user to Debugger Users group
Typically user needs to be admin
Remote Debugging And
Windows XP SP2
How to enable remote debugging on
Windows XP Service Pack 2
Need to configure Internet Connection
Firewall (ICF)
Also need to configure DCOM if not admin
on remote machine
Further details @
http://msdn.microsoft.com/library/enus/dnwxp/html/xpsp2remotedebug.asp
Symbol Server
New Feature for 7.1
Automatically finds symbols from indexed
symbol stores
Automatically finds binaries too
(for reading minidumps)
Uses weird symbol path syntax
Not officially supported in 7.0, but
Get symsrv.dll from web (see later)
Copy symsrv.dll next to devenv.exe
“srv*” -> “symsrv*symsrv.dll*”
Symbol Server Path Syntax
Goes in Project Properties, Symbol Path
For minidumps, add command
argument: MODPATH=
srv*[localcache*]remotepath
Remote path can be UNC path (internal)
or http: address (external)
A local cache makes things much faster
after the first time
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
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
Can select which debugger
to attach with
Debugging Script
Client-side script
Standalone script
wscript.exe Test.vbs //X (or //D)
Script running in a Web Application
Use Running Documents window
Server-side script
Classic ASP pages
Some configuration required
Debugging Script
Scott Nonnenberg
Program Manager
Visual Studio Debugger
Testing Your ASP.NET
Application Using Different
Browsers
Visual Studio always uses
Internet Explorer when debugging
an ASP.NET application
What if you want to debug using
other browsers?
Using A Non-Internet Explorer
Browser For Debugging
Scott Nonnenberg
Program Manager
Visual Studio Debugger
Multi-Developer Debugging On
Internet Information Server 6.0
With Internet Information Server 6.0
(IIS 6.0), multiple developers can debug
on the same Web Server
Three steps required:
Create an application pool
Configure the application pool
Change the properties for
the web application to use
the new application pool
Multi-Developer
Debugging On IIS 6.0
Habib Heydarian
Program Manager
Visual Studio Debugger
Enterprise Production
Debugging
Visual Studio supports production
debugging via:
Dumps and NTSD extensions (SOS.dll)
“Live” remote debugging
Using SOS To Debug Dumps
What is SOS?
“Son of Strike”
NTSD extension
What is it used for?
Debugging memory leaks
Debugging contention (deadlock) issues
Debugging unexpected process
termination
Using SOS
Habib Heydarian
Program Manager
Visual Studio Debugger
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
Debugging XML Web
Services
Scott Nonnenberg
Program Manager
Visual Studio Debugger
SQL Server Debugging
Two ways
1. Use Server Explorer
Debug stored procedures and functions
2. Call procedure from application
Set breakpoint
Enable SQL debugging
Debugging SQL Server
Habib Heydarian
Program Manager
Visual Studio Debugger
Code Instrumentation Options
Do-it-yourself (not recommended)
.NET Tracing
System.Diagnostics
ASP.NET Tracing
Enterprise Instrumentation Framework
Tracing In .NET
Available for all .NET application types
System.Diagnostics
Debug
Trace
Conditionally compiled
Extensible output via TraceListeners
File, Debugger, Event Log
Configured via file (.config)
ASP.NET Tracing
Configuration:
Page-level
<%@ Page Trace=“true”%>
Application-level (trace.axd)
web.config
Outputs to browser
ASP.NET Tracing
Enterprise Instrumentation Framework
Available on MSDN
Very extensible
Events, EventCategories
Filters
EventSinks
Event Log, WMI, Windows Trace Service
Configuration via file
Read at startup and when changed
Scriptable API
.NET Tracing Versus EIF
.NET
EIF
On-the-fly Configuration
No
Yes
Extensible Event Types
No
Yes
Separate Installation Required
No
Yes
Performance Overhead
Yes
Yes
Output Shown in Debugger
Yes
No
Enterprise Instrumentation
Framework Demo
Scott Nonnenberg
Program Manager
Visual Studio Debugger
Enterprise Instrumentation Framework
http://msdn.microsoft.com/vstudio/productinfo/enterprise/eif/
Developer Centers on MSDN
http://msdn.microsoft.com/vcsharp
http://msdn.microsoft.com/vbasic
http://msdn.microsoft.com/visualc
http://msdn.microsoft.com/vjsharp
Debugger Team Blogs
http://blogs.msdn.com/scottno
http://msdn.microsoft.com/vcsharp/team/blogs/#debugger
Please fill out a session evaluation on CommNet
Q1: Overall satisfaction with the session
Q2: Usefulness of the information
Q3: Presenter’s knowledge of the subject
Q4: Presenter’s presentation skills
Q5: Effectiveness of the presentation
Questions?
© 2004 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.