dev450 visual studio: best practices for debugging managed applications habib heydarian scott...

Post on 22-Dec-2015

230 Views

Category:

Documents

3 Downloads

Preview:

Click to see full reader

TRANSCRIPT

DEV450 Visual Studio: Best Practices For Debugging Managed Applications

DEV450 Visual Studio: Best Practices For Debugging Managed Applications

Habib HeydarianHabib HeydarianScott NonnenbergScott NonnenbergProgram ManagersProgram ManagersMicrosoft CorporationMicrosoft Corporation

OverviewOverview

Setting up for debuggingSetting up for debuggingEnvironmentEnvironment

Symbol serverSymbol server

JIT debuggingJIT debugging

ASP.NET DebuggingASP.NET DebuggingWeb ApplicationsWeb Applications

Web ServicesWeb Services

Debugging SQL ServerDebugging SQL Server

Instrumentation and TracingInstrumentation and Tracing

Setting Up For Debugging Setting Up For Debugging

Generate a debug buildGenerate a debug buildGenerates debugging info (pdb file)Generates debugging info (pdb file)

F5 or attachF5 or attach

Customize F5Customize F5Remote launchRemote launch

Launch URLLaunch URL

Launch executableLaunch executable

Launch debuggersLaunch debuggers

Remote Debugger SetupRemote Debugger Setup

1.1. Setup debug components on remote machineSetup debug components on remote machine

Remote DebuggingRemote Debugging

2.2. Add user to Debugger Users groupAdd user to Debugger Users group

3.3. Typically user needs to be adminTypically user needs to be admin

Local Machine Remote Machine

Remote Debugging And Windows XP SP2Remote Debugging And Windows XP SP2

How to enable remote debugging on How to enable remote debugging on Windows XP Service Pack 2Windows XP Service Pack 2

Need to configure Internet Connection Need to configure Internet Connection Firewall (ICF)Firewall (ICF)

Also need to configure DCOM if not admin Also need to configure DCOM if not admin on remote machineon remote machine

Further details @ Further details @ http://msdn.microsoft.com/library/en-us/dhttp://msdn.microsoft.com/library/en-us/dnwxp/html/xpsp2remotedebug.aspnwxp/html/xpsp2remotedebug.asp

Symbol ServerSymbol Server

New Feature for 7.1New Feature for 7.1

Automatically finds symbols from indexed Automatically finds symbols from indexed symbol storessymbol stores

Automatically finds binaries tooAutomatically finds binaries too(for reading minidumps)(for reading minidumps)

Uses weird symbol path syntaxUses weird symbol path syntax

Not officially supported in 7.0, butNot officially supported in 7.0, butGet symsrv.dll from web (see later)Get symsrv.dll from web (see later)

Copy symsrv.dll next to devenv.exeCopy symsrv.dll next to devenv.exe

““srv*” -> “symsrv*symsrv.dll*”srv*” -> “symsrv*symsrv.dll*”

Symbol Server Path SyntaxSymbol Server Path Syntax

Goes in Project Properties, Symbol PathGoes in Project Properties, Symbol Path

For minidumps, add command For minidumps, add command argument: MODPATH=argument: MODPATH=

srv*[srv*[localcachelocalcache*]*]remotepathremotepath

Remote path can be UNC path (internal) Remote path can be UNC path (internal) or http: address (external)or http: address (external)

A local cache makes things much faster A local cache makes things much faster after the first timeafter the first time

JIT DebuggingJIT Debugging

““Just In Time” (JIT) DebuggingJust In Time” (JIT) DebuggingAllows you to debug crashes (exceptions) Allows you to debug crashes (exceptions) when application is not running under the when application is not running under the debuggerdebugger

Default is off for Windows FormsDefault is off for Windows Forms

Can select which debugger Can select which debugger to attach withto attach with

<configuration><configuration> <system.windows.forms jitDebugging="true" /><system.windows.forms jitDebugging="true" /></configuration></configuration>

Debugging ScriptDebugging Script

Client-side scriptClient-side scriptStandalone scriptStandalone script

wscript.exe Test.vbs //X (or //D)wscript.exe Test.vbs //X (or //D)

Script running in a Web ApplicationScript running in a Web ApplicationUse Running Documents windowUse Running Documents window

Server-side scriptServer-side scriptClassic ASP pagesClassic ASP pages

Some configuration requiredSome configuration required

Debugging ScriptDebugging ScriptScott NonnenbergScott NonnenbergProgram ManagerProgram ManagerVisual Studio DebuggerVisual Studio Debugger

Testing Your ASP.NET Application Using Different Browsers

Testing Your ASP.NET Application Using Different Browsers

Visual Studio always uses Visual Studio always uses Internet Explorer when debugging Internet Explorer when debugging an ASP.NET applicationan ASP.NET application

What if you want to debug usingWhat if you want to debug usingother browsers?other browsers?

Using A Non-Internet Explorer Using A Non-Internet Explorer Browser For DebuggingBrowser For Debugging

Scott NonnenbergScott NonnenbergProgram ManagerProgram ManagerVisual Studio DebuggerVisual Studio Debugger

Multi-Developer Debugging On Internet Information Server 6.0Multi-Developer Debugging On Internet Information Server 6.0

With Internet Information Server 6.0 With Internet Information Server 6.0 (IIS 6.0), multiple developers can debug (IIS 6.0), multiple developers can debug on the same Web Serveron the same Web Server

Three steps required:Three steps required:Create an application poolCreate an application pool

Configure the application poolConfigure the application pool

Change the properties for Change the properties for the web application to use the web application to use the new application poolthe new application pool

Multi-Developer Multi-Developer Debugging On IIS 6.0 Debugging On IIS 6.0

Habib HeydarianHabib HeydarianProgram ManagerProgram ManagerVisual Studio DebuggerVisual Studio Debugger

Enterprise Production DebuggingEnterprise Production Debugging

Visual Studio supports production Visual Studio supports production debugging via:debugging via:

Dumps and NTSD extensions (SOS.dll)Dumps and NTSD extensions (SOS.dll)

““Live” remote debuggingLive” remote debugging

Using SOS To Debug DumpsUsing SOS To Debug Dumps

What is SOS?What is SOS?““Son of Strike”Son of Strike”

NTSD extensionNTSD extension

What is it used for?What is it used for?Debugging memory leaksDebugging memory leaks

Debugging contention (deadlock) issuesDebugging contention (deadlock) issues

Debugging unexpected process Debugging unexpected process terminationtermination

Using SOSUsing SOSHabib HeydarianHabib HeydarianProgram ManagerProgram ManagerVisual Studio DebuggerVisual Studio Debugger

Debugging XML Web ServicesDebugging XML Web Services

You can debug an XML Web Service:You can debug an XML Web Service:On its ownOn its own

Called from a ASP.NET Web FormCalled from a ASP.NET Web Form

Called from a client applicationCalled from a client application

That is already runningThat is already running

Debugging XML Web Debugging XML Web ServicesServicesScott NonnenbergScott NonnenbergProgram ManagerProgram ManagerVisual Studio DebuggerVisual Studio Debugger

SQL Server DebuggingSQL Server Debugging

Two waysTwo ways1.1. Use Server ExplorerUse Server Explorer

Debug stored procedures and functionsDebug stored procedures and functions

2.2. Call procedure from applicationCall procedure from applicationSet breakpointSet breakpoint

Enable SQL debuggingEnable SQL debugging

Debugging SQL ServerDebugging SQL Server

Habib HeydarianHabib HeydarianProgram ManagerProgram ManagerVisual Studio DebuggerVisual Studio Debugger

Code Instrumentation OptionsCode Instrumentation Options

Do-it-yourself (not recommended)Do-it-yourself (not recommended)

.NET Tracing.NET TracingSystem.DiagnosticsSystem.Diagnostics

ASP.NET TracingASP.NET Tracing

Enterprise Instrumentation FrameworkEnterprise Instrumentation Framework

Tracing In .NETTracing In .NET

Available for all .NET application typesAvailable for all .NET application types

System.DiagnosticsSystem.DiagnosticsDebugDebug

TraceTrace

Conditionally compiledConditionally compiled

Extensible output via TraceListenersExtensible output via TraceListenersFile, Debugger, Event LogFile, Debugger, Event Log

Configured via file (.config)Configured via file (.config)

ASP.NET TracingASP.NET Tracing

Configuration:Configuration:Page-levelPage-level

Application-level (trace.axd)Application-level (trace.axd)web.configweb.config

Outputs to browserOutputs to browser

<%@ Page Trace=“true”%><%@ Page Trace=“true”%>

ASP.NET TracingASP.NET Tracing

Enterprise Instrumentation FrameworkEnterprise Instrumentation Framework

Available on MSDNAvailable on MSDN

Very extensibleVery extensibleEvents, EventCategoriesEvents, EventCategories

FiltersFilters

EventSinksEventSinksEvent Log, WMI, Windows Trace ServiceEvent Log, WMI, Windows Trace Service

Configuration via fileConfiguration via fileRead at startup and when changedRead at startup and when changed

Scriptable APIScriptable API

.NET Tracing Versus EIF.NET Tracing Versus EIF

.NET.NET EIFEIF

On-the-fly ConfigurationOn-the-fly Configuration NoNo YesYes

Extensible Event TypesExtensible Event Types NoNo YesYes

Separate Installation RequiredSeparate Installation Required NoNo YesYes

Performance OverheadPerformance Overhead YesYes YesYes

Output Shown in DebuggerOutput Shown in Debugger YesYes NoNo

Enterprise Instrumentation Enterprise Instrumentation Framework DemoFramework Demo

Scott NonnenbergScott NonnenbergProgram ManagerProgram ManagerVisual Studio DebuggerVisual Studio Debugger

Enterprise Instrumentation FrameworkEnterprise Instrumentation Frameworkhttp://msdn.microsoft.com/vstudio/productinfo/enterprise/eif/http://msdn.microsoft.com/vstudio/productinfo/enterprise/eif/

Developer Centers on MSDNDeveloper Centers on MSDNhttp://msdn.microsoft.com/vcsharphttp://msdn.microsoft.com/vcsharphttp://msdn.microsoft.com/vbasichttp://msdn.microsoft.com/vbasichttp://msdn.microsoft.com/visualchttp://msdn.microsoft.com/visualchttp://msdn.microsoft.com/vjsharphttp://msdn.microsoft.com/vjsharp

Debugger Team BlogsDebugger Team Blogshttp://blogs.msdn.com/scottnohttp://blogs.msdn.com/scottno http://http://msdn.microsoft.com/vcsharp/team/blogs/#debuggermsdn.microsoft.com/vcsharp/team/blogs/#debugger

Q1:Q1: Overall satisfaction with the sessionOverall satisfaction with the session

Q2:Q2: Usefulness of the informationUsefulness of the information

Q3:Q3: Presenter’s knowledge of the subjectPresenter’s knowledge of the subject

Q4:Q4: Presenter’s presentation skillsPresenter’s presentation skills

Q5:Q5: Effectiveness of the presentationEffectiveness of the presentation

Please fill out a session evaluation on CommNetPlease fill out a session evaluation on CommNet

Questions?Questions?

© 2004 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

top related