20
Index Symbols ! (exclamation marks), and invalid breakpoints, 106 #Region directive, E&C, 143-144 $500 million exception, 217-218 * (asterisks), and Cordbg commands, 155 .NET Framework bug, 406 II as prefix for VB .NET comments, 145 I adv switch, Ildasm, 158 Idebug compiler options and, 82 described,81-82 loptimize, and compiler options, 82-83 loptimize flag, 81-82 Isource argument, Ildasm, 158 ? (question marks), and breakpoint state, 107 @@error variable, 350, 352 > (greater-than) character, and Visual Studio windows, 94 o (diamonds), and breakpoint state, 107 Numbers 49.7 bug, 29 500-Mile E-mail bug, 456-457 A abstractions, leaky, 466 Account Class (code), 435-436 AcquireReaderLock method, 441-442 AcquireWriterLock method, 442 active debugger process, setting, 138-139 actor argument, 258 address breakpoint type described, 75,103 setting, 100 AJ)epends, 170-171 AfierDeserialize, 265, 273 AfierSerialize, 265, 266, 273 Airbus A320 airliner, 69 alert utility, 166 algorithms Bubble sort algorithm, 149, 150 Counting sort algorithm, 149, 150 Quick sort algorithm, 149, 150 Selection sort algorithm, 149, 150 sort algorithms, testing, 149-150 aliases, and Visual Studio, 95-96 ambiguous overloading, 34-36 Ambiguous Overloading (code), 34-35 apartment threading, 421 ApplicationException,372 applications application errors, and writing code, 363-364 application knowledge and debug- ging with Visual Studio .NET, 76 ASP.NET debugging and application -level, 303-306 configuring, 287-291 configuring project, 289-291 distributed applications, 459-466 dealing with failure, 459-464 dealing with leaky abstractions, 466 dealing with state, 464-465 message semantics, 465-466 monitoring, 481-482 production applications, debugging, l39-140 support department, and solving errors, 365-366 symbols management, 140 that make SQL server calls, debug- ging, 346-351 from inside Visual Studio, 348-351 from outside Visual Studio, 351 setup, 346-348 tracing and instrumentation application development team and,185 application end users and, 184 application support team and, 184-185 Windows Forms applications. See Windows Forms applications, strategic design issues availability, 10-14 measuring, 12 software availability design, 13-14 software availability, improving, 14 understanding, 10-11 485

Index [link.springer.com]978-1-4302-0778-8/1.pdf · simple (location breakpoints), ... C++, and exception ... Call Stack windows debug symbols management and, 140 examining program

Embed Size (px)

Citation preview

Index

Symbols ! (exclamation marks), and invalid

breakpoints, 106 #Region directive, E&C, 143-144 $500 million exception, 217-218 * (asterisks), and Cordbg commands,

155 .NET Framework bug, 406 II as prefix for VB .NET comments, 145 I adv switch, Ildasm, 158 Idebug

compiler options and, 82 described,81-82

loptimize, and compiler options, 82-83 loptimize flag, 81-82 Isource argument, Ildasm, 158 ? (question marks), and breakpoint

state, 107 @@error variable, 350, 352 > (greater-than) character, and Visual

Studio windows, 94 o (diamonds), and breakpoint state, 107

Numbers 49.7 bug, 29 500-Mile E-mail bug, 456-457

A abstractions, leaky, 466 Account Class (code), 435-436 AcquireReaderLock method, 441-442 AcquireWriterLock method, 442 active debugger process, setting, 138-139 actor argument, 258 address breakpoint type

described, 75,103 setting, 100

AJ)epends, 170-171 AfierDeserialize, 265, 273 AfierSerialize, 265, 266, 273 Airbus A320 airliner, 69 alert utility, 166 algorithms

Bubble sort algorithm, 149, 150 Counting sort algorithm, 149, 150 Quick sort algorithm, 149, 150 Selection sort algorithm, 149, 150 sort algorithms, testing, 149-150

aliases, and Visual Studio, 95-96 ambiguous overloading, 34-36 Ambiguous Overloading (code), 34-35 apartment threading, 421 ApplicationException,372 applications

application errors, and writing code, 363-364

application knowledge and debug­ging with Visual Studio .NET, 76

ASP.NET debugging and application -level, 303-306 configuring, 287-291 configuring project, 289-291

distributed applications, 459-466 dealing with failure, 459-464 dealing with leaky abstractions,

466 dealing with state, 464-465 message semantics, 465-466 monitoring, 481-482

production applications, debugging, l39-140

support department, and solving errors, 365-366

symbols management, 140 that make SQL server calls, debug­

ging, 346-351 from inside Visual Studio,

348-351 from outside Visual Studio, 351 setup, 346-348

tracing and instrumentation application development team

and,185 application end users and, 184 application support team and,

184-185 Windows Forms applications. See

Windows Forms applications, strategic design issues

availability, 10-14 measuring, 12 software availability design,

13-14 software availability, improving, 14 understanding, 10-11

485

Index

486

applications, strategic design issues ( Continued)

reliability,4-10 measuring, 6-7 of software, 7-10 understanding, 4-5

ArgumentException, 383-384, 385 Arnold, Ken, 463 ASP.NET debugging, 277-308

AspNetDebugDemo application, 291-299

application-level error handling, 297-299

ASP.NET error handling, 293 basics of, 291-293 no error handling, 293-295 page-level error handling, 296-297 procedure-level error handling,

295 gorilla testing, 307-308 lIS debugging, 277-283

authentication and, 281-282 multithreading and, 282-283 process recycling with lIS 5.x,

279-280 process recycling with lIS 6.0, 280 production debugging, 283 simultaneous, with lIS S.x, 278 simultaneous, with lIS 6.0, 278 URLScan, lIS and DEBUG verb,

280-281 preparation, 283-291

application configuration, 287-291

Internet Explorer configuration, 286-287

remote server debugging, 286 user account permissions,

283-285 summary, 307 tracing, 300-306

application-Ievel,303-306 page-Ievel,300-303

Web services debugging and ASP.NET user accounts, 242 worker process debugging, 242

assembly dependencies, viewing. See ADepends

assembly permissions, viewing. See Perm View

Assert methods, 190-192 assertions

Assert and Fail methods and, 190-192 assertion redirection, and tracing, 210 using, 192-193

asterisk (*), and Cordbg commands, 155 audit trails, 366 authentication, and lIS debugging,

281-282 Autos windows, 111-112

B Bank Class (code), 432-433 BeforeDeserialize, 265, 266, 273 BeforeSerialize, 265 BestValue variable, 228, 229 binding, static and dynamic, defined, 51 Bohrbugs, 238 Bold Performer bug, 178-179 boolean switches, activating, 209 BooleanSwitch class, and trace controls,

202,203 boxing

boxing conversions dangers, 57-58 defined,57

Boxing Can Be Dangerous (code), 58 breakpoints, 99-107

advanced, 75-76, 103-106 basics of, 99-101 breaking into applications and, 223 breakpoint state, 106-107 conditional, 228, 229, 230 defined, 100 hitting, and Windows Forms appli­

cations, 224-225 reasons for not being hit, 224-225 simple (location breakpoints),

101-103 SQL debugging limitations and, 352

Breakpoints windows, 226 Bubble sort algorithm, 149, 150 Bug Dictionary, 238-239 Bug from Hell, 180-181 bugs

finding, Windows Forms appli­cations, 227-229

types of. See also Bug Dictionary 49.7,29 Deliberate Excel, 30 latency, 17 Lunch Games, 31 Margarita, 30 Musical,30 Phase of the Moon, 29 semantic, 17 sequencing, 16

with worst effects, 10 build configurations

effects of, 80-84

C C#

from the command line, 81-83 debug symbol files, locating,

83-84 source files, locating, 84 in Visual Studio, 81

project build configuration, 137-138 solution build configuration, 132-133

class member overloading and ambiguous overloading, 34-35

C# vs. VB .NET, 36-38 example of, 38-40

confusion between VB .NET and, 55-57 C# Translation of Listing 2-18 (code), 56 C# Translation of Listing 2-3 (code), 37 C# Translation of Listing 2 -5 (code), 39-40 C++, and exception handling, 396, 397 Cahners Instat, 4 Call Stack windows

debug symbols management and, 140 examining program state and, 227 IDE debugging and, 114-115 SQL debugging limitations and, 352

Cashier Class (code), 434-435 Catch blocks

debugging exceptions and, 401 exception behavior, analyzing and, 416 Thread.Abort method and, 455 Try ... Catch ... Finally and, 372-373,

374,375 categories

relationship to counters and instances, 213

sorting, 214 characters, and breakpoint state,

106-107 chart utility, 166 chess, and debugging, 484 Chr(O), and IDE debugging, 119-120 CIL. See Common Intermediate

Language (CIL) CIL Produced by On Error Resume Next

(code), 161-163 CIL Produced by Try ... Catch ... Finally

(code), 164-165 class libraries, debugging, 232-233 class member overloading, 34-40

ambiguous, 34-36 C# overload, 38-40 C# vs. VB .NET, 36-38 described, 34 function breakpoints, adding, 102

client proxy, debugging, 252-253 clients, nonlocal, and Web service

exceptions, 262 CLR. See Common Language Runtime

(CLR) code

cleanup code, 376 code optimization, 146-150

basics of, 146-148 as enemy, 148 test of, 149-150

code optimization flag, 79 debugging vs. testing, 19-20 editing. See E&C (Edit and Continue) end users and error-handling code,

363-364 error handling and diagnostics code,

and developers, 366-367

how not to write, 355-357 Ildasm code, 159-166 managed code

]IT debugging and, 91-92 vs. unmanaged, and COM Interop,

322 obfuscated VB .NET code, 151 recovery code, 376 service installation code, debugging,

316-317 source code

CLR, 327 multithreading and, 423

tracing code, 183 tricky debugging situations and

focus code, 230 keyboard code, 231 mouse handling code, 231 window painting code, 229-230

unmaintainable code, 355-357 unmanaged code

]IT debugging and, 92-93 vs. managed, and COM Interop,

322 working backward through, 121

code argument, 258 COM Interop

COM versioning problems, overcom­ing, 333-337

introduction to, 321 VB 6.0 application using VB .NET

component, 329-333 COM Interop application debug­

ging, 332-333 VB.Classic preparation, 331 VB .NET preparation, 330

VB .NET applications using VB 6.0 components, 323-329

COM Interop application debug-ging, 326-327

tips, 327-328 VB 6.0 debugger, 328-329 VB.Classic preparation, 323-324 VB .NET preparation, 325-326

COM Interoperability. See COM Interop command line

build configuration effects from, 81-83

Ildasm and, 158 PermViewand, 173

Command window, 93-94, 95-96 commands, Cordbg, 155-156 Common Intermediate Language (CIL)

debugging, 144-146 disassembler. See Ildasm generated from test methods, 160-165

CIL Produced by On Error Resume Next, 161-163

CIL Produced by Try ... Catch ... Finally, 164-165

Index

487

Index

488

Common Language Runtime (CLR) exceptions, 397-398

breaking into debugger and, 400 controlling debugger handling of,

397-398 custom, adding, 400 unhandled and, 401-402, 405,

406-408,411-412 terminating managed threads and, 455

communications component communication

coupling, 15 format, 15 wire protocol, 15

debugging issues, 16-18 If in Doubt, Ask, 319-320

compatibility requirements, SQL, 339-340

compensatory transactions, 462-463 compilers

confusion between developers and, 53-55

JIT compiler, 78-79, 80 options

/debug compiler options, 82 / optimize compiler options, 82-83

VB .NET compiler, 79-80 VB .NET language compiler, 79-80 Visual Studio debugger and, 78-79

components communication between

component coupling, 15 format, 15 wire protocol, 15

HeartbeatMonitor, 474-475 remote debugging of, 467

Compoundbugs, 238 ComPrintUtils.vbp project. SeeVB .NET,

VB .NET applications using VB 6.0 components

conditional expression modifier, 104-106

connection pooling defined, 353 SQL debugging limitations and, 353

consistency, 48 console debugging. See Cordbg debugger constructors. See exception construc-

tors, building Continue. See E&C (Edit and Continue) controls

control designers, debugging, 237 threads and, 449 Windows Forms controls, debugging,

233-236 Cordbg debugger, 153-157

code optimization and, 147 commands, 155-156 use of, 153-155

CountCoordinator class, 427-428

CountCoordinator Class (code), 427-428 Counting sort algorithm, 149, 150 CountWorker Class (code), 428-429 Crawling Horror bug, 179-180 CurrentTime Web method, 245, 246, 247,

248,249-250 custom exceptions

catching and throwing, 385-386 described, 369 properties

adding, 390-391 serializing, 392-394

remoting and, 394-395 summary, 395

Custom Trace Listener for Recording Performance Data (code), 199-201

CustomErrors Setting in TimeServer's Web.config (code), 262

CustomErrors, setting in Web.config, 262,288-289

D data, importance of saving, 364 data races, 426, 427-431, 430 Dataquest study, 10-11 Dbgclr debugger, 157-158 Dean, James, 275-276 Debug class, and tracing and instru­

mentation, 211-212 Debug configuration, Visual Studio

code optimization and, 147 described, 81 solution build configuration and, 132

DEBUG keyword, 280-281 Debug Setting in TimeServer's

Web.config (code), 244 debug symbols

debug symbol files importance of, 116 locating, 83-84 search paths, 131

managementoL 140-143 symbol server, 142-143 symbols for applications, 140 symbols for framework SDK, 141 symbols for Windows, 140-141

DEBUG verb, 280-281 DebuggableAttribute class, 79 DebuggerStepthroughAttribute, 253 Debugging Applications (Microsoft

Press,2000),19-20 debugging scaffold, 23 debugging, strategic issues. See VB .NET

strategic debugging issues debugging tools, 153-181. See also trac­

ing and instrumentation; Visual Studio .NET debugger; Visual Studio .NET debugger, using

AJ)epends, 170-171 Cordbg, 153-157

commands, 155-156 use of, 153-155

Dbgclr, 157-158 Ildasm, 158-166

code, 159-166 from the command line, 158 within Visual Studio, 158

memorable bugs, 178-181 performance monitoring, 166-170

basics of, 166-167 testing string performance,

167-170 PermView, 171-177

basics of, 171-173 from the command line, 173 permissions, 173-177 within Visual Studio, 173

summary, 178 DebugMode Property, 234, 235, 236 Decimal datatype, 66, 67 DefaultTraceListener, 194-195 Deliberate Excel bug, 30 deployed Web services, debugging,

253-254 design, and tracing and instrumentation

diagnosis, 187 Detail XML node, 258 developers

catching and swallowing System. Exception and, 377

confusion between compilers and, 53-55

debugging developer psychology. See alsoE&C

psychological factors, 25-28 error handling requirements of,

366-368 exceptions and, 361-362

diagnosis, tracing and instrumentation application development team, 185 application end users, 184 application support team, 184-185 diagnostic categories, 185-187

diamonds (0), and breakpoint state, 107 Disassembly windows

IDE debugging and, 117-118 Visual Studio debugging and, 76, 77

distributed debugging, 75 distributed systems, debugging, 459-484

distributed applications basics, 459-466

failure and, 459-464 leaky abstractions and, 466 message semantics and, 465-466 state and, 464-465

distributed systems, defined, 459 HeartbeatMonitor, 474-481

debugging, 477-481

installing, 475-477 introduction to, 474-475

How Good Are You?, 483-484 monitoring distributed applications,

481-482 remote debugging basics, 466-467 remote debugging preparation,

468-474 full remote debugging installation,

471-472 installation, 469-470 native remote debugging instal­

lation, 470-471 remote debugging restrictions,

472-474 summary, 483

distributed transactions, 462 Division By Zero (code), 59-61 DLL Hell, 322 DoSort function, 225, 226 Double Trouble (code), 67 doubles

ambiguous overloading and, 35 floating-point Double variables,

65-66,67 dump bin utility, 83-84 dynamic binding, defined, 51 dynamic link libraries (DLLs). See class

libraries

E E&C (Edit and Continue)

coping without, 143-144 debugging options, Visual Studio,

126-127 living without, VB .NET

debugging with, 20-21, 22 proto typing with, 23 unit testing with, 21-22, 22 workarounds for, 23-25

enabled attribute, 304 end users

expectations for software, 361 requirements for error handling,

363-364 engineers, and communications,

319-320 environment, and application failure, 5 eqUality, and VB .NET inheritance, 45-49 error handling, 361-420

ASP.NET, 293 AspNetDebugDemo application

application-level error handling, 297-299

no error handling, 293-295 page-level error handling, 296-297 procedure-level error handling, 295

error handling requirements, 363-369

developer, 366-368

Index

489

Index

490

error handling (Continued) end user, 363-364 logging exceptions, 368-369 operations support, 365-366

On Error Resume Next, and Ildasm, 159-160

exceptions vs. errors, 361-363 haiku error messages, 418-420 managed vs. unmanaged code, and

COM Interop, 322 software reliability and, 9 summary, 417 Try ... Catch ... Finally and Ildasm and,

159-160 Error Handling Comparison (code),

159-160 ErrorPage property, 296, 297 EventLogTraceListener, 197-198 Evil Type Coercion, VB.Classic, 134 Example of an Assertion Message

(code),191-192 examples

class member overloading, 38-40 Example of an Assertion Message

(code), 191-192 PermView

Assembly Must Be Able to Read Part of the Registry (code), 176

Assembly Must Be Able to Use Assertions (code), 177

Assembly Must Be Able to Use the Clipboard (code), 176-177

Assembly Must Be Allowed to Read Anything in a Specific Folder (code), 175-176

Assembly Must Execute with Full Trust (code), 174

Assembly Must Execute with Internet Trust (code), 174-175

Assembly Must Have Access to System Dialog Boxes (code), 177

Assembly Must Have Full Rights to a Specific File and Folder (code), 175

sample solution, exception manage­ment, 417

Twilight Zone bug as example of Schroedinbugs, 179

Excel bug, 30 exception constructors, building, 388 Exception Management Application

Block,414-415 Exception Produced by the

ThrowExceptionRaw Web Method (code), 248

exceptions, 369-417 basics of management of, 369-370 catching, reasons for, 376 custom exceptions, building, 387-395

custom exception properties, adding, 390-391

custom exceptions and remoting, 394-395

custom exceptions properties, serializing, 392-394

custom exceptions, serializing, 389-390

custom exceptions summary, 395 exception constructors, building,

388 exception names, choosing, 387 parent exceptions, choosing, 387

debugging, 396-401 controlling exceptions, 396-398 custom exceptions, adding, 400 debugger, breaking into, 400-401 first-chance exceptions, 398-399 unhandled exceptions, 399

exception behavior, analyzing, 415-417

exception management application block,414-415

exceptions vs. errors, 361-363 logging exceptions and error han-

dling requirements, 368-369 sample solution, 417 storing, 368 swallowing, and developer code writ-

ing, 367 System. Exception class, 370-372 thread exceptions, 453-454 throwing

alternative code paths and, 367 cleanup and, 367 documentation of, 367 numbers and, 59-63 points for code writing and, 367

Try ... Catch ... Finally and, 375-386 automatic propagation of,

375-376 catching and rethrowing

System.Exception, 378 catching and swallowing

System. Exception, 376-378 catching exceptions and throwing

better exceptions, 384-385 catching exceptions and throwing

custom exceptions, 385-386 catching exceptions and throwing

new exceptions, 378-384 special exceptions, handling, 386

unhandled exceptions, dealing with, 401-414

basics of, 401-405 unhandled exception filter, 405-407 unhandled exception filter when

realistic,407-409 in Windows Forms, 410-413 in XML Web services, 413-414

Web service failures, handling and exception details, hiding, 260-263 exception flow, 254-255 exceptions, improving, 255-260 unhandled exceptions, trapping,

263 exclamation marks (!), and invalid

breakpoints, 106 ExecutionEngineException, 386

F fail-fast principle, 9 Fail methods, and trace creation,

190-192 failure

in distributed applications, 459-464 basics of, 459-462 compensatory transactions,

462-463 distributed transactions, 462 idempotent transactions, 463 local vs. remote method calls,

459-460 "swaying with the earthquake",

463 partial vs. complete, 460-461 possible causes of, 5 reconstructing, 274-276 Web service failures, handling,

254-263 exception details, hiding,

260-263 exception flow, 254-255 exceptions, improving, 255-260 unhandled exceptions, trapping,

263 Failure Analysis Associates (FAA),

275-276 false value, and Double value, 66 file breakpoint type

described, 75 setting, 100

File.Move, 379, 380, 381 files

debug symbol files, 83-84 importance of in debugging, 116 locating, 83-84 search paths, 131

source files locating, 84 search paths, 130-131

XML configuration file, and TimeServer, 244

Finally blocks exception behavior analysis and, 417 Thread.Abort method and, 455 Try ... Catch ... Finally and, 372, 374,

375,378 unhandled exceptions and, 404

finite state machines, 16

first-chance exceptions, 397, 398-399 Five Hundred Mile E-mail bug, 456-457 five hundred million dollar exception,

217-218 flags, and DebuggableAttribute class, 79,

80,81,82 floating-point divisions, 59-61, 62. See

also NaN floating-point issues

divisions, 59 floating-point Double variables,

65-66 floating-point value Infinity, 62,

63-64 inexact numbers and, 67

focus code, 230 folklore of debugging, 29-31 Forrester, Justin, 307 "fragile base class" problem, 41 framework

.NET learning, 25 symbols for, 141

SDK, management of symbols for, 141 free threading, 421 freezing threads, 447-448 Friend keyword, 51 function breakpoint type

described, 75, 102 setting, 100

fuzz testing tool, 307-308

G Gartner Group, 4 globally unique identifiers (GUIDs), and

managed vs. unmanaged code, 322

gorilla testing, 307-308 graphical user interface (GUI), and unit

testing, 22, 24 greater-than (» character, and Visual

Studio windows, 94 Green, Roedy, 355 GUI, debugger. See Dbgclr debugger GUIDs (globally unique identifiers), and

H

managed vs. unmanaged code, 322

haiku error messages, 418-420 hardware, and application failure, 5 Harris, Trey, 456 health monitoring

lIS 5.x and, 279 lIS 6.0 and, 280

HeartbeatMonitor, 474-481 debugging, 477-481 heartbeats, defined, 474 installing, 475-477 introducing, 474-475

Index

491

Index

492

Heisenbugs, 238 HelpLink System. Exception property,

371 hexadecimals, 124 Hide the Furniture bug, 180 hit count modifier, 103-104 HKEY_LOCAL_MACHINE (HKLM)

HT debugger and managed code settings, 91-92 unmanaged code settings, 92-93

unhandled exception filter consider-ations and, 406

How Good Are You?, 483-484 HResult System. Exception property, 371 HTTP POST transmission, vs. SOAP, 247 human error, and application failure,S

I IDE debugging, 93-118

Autos windows, 111-112 basics of, 84-86 breakpoints, 99-107

advanced, 103-106 basics of, 99-101 breakpoint state, 106-107 simple, 101-103

Call Stack windows, 114-115 Disassembly windows, 117-118 exceptions debugging

controlling handling of, 396-398 first -chance exceptions, 398-399 unhandled exceptions, 399

Immediate/Command window, 93-96

issues, 118-120 Chr(O)' 119-120 debugger single-stepping, 120 refusing to appear, 118-119

Locals windows, 109-111 Me windows, 113 Modules windows, 115-116 Output windows, 96-67 QuickWatch windows, 109 Running Documents windows, 118 Source windows, 97-99 Threads windows, 118 Watch windows, 107-108

idempotent transactions, 463 If mode=Off, 289 If mode=On, 289 If mode=RemoteOnly, 289 lIS 5.0, Web services debugging and, 242 lIS 5.x

basics of, 277 process recycling with, 279-280 simultaneous debugging with, 278

lIS 6.0 process recycling with, 280 simultaneous debugging with, 278

lIS debugging, 277-283 authentication and, 281-282 multithreading and, 282-283 process recycling with lIS 5.x,

279-280 process recycling with lIS 6.0, 280 production debugging, 283 simultaneous, with lIS 5.x, 278 simultaneous, with lIS 6.0, 278 URLScan, lIS and DEBUG verb,

280-281 Ildasm, 158-166

code, 159-166 from the command line, 158 within Visual Studio, 158

Immediate window, 93-95 Infinity, floating-point value, 62, 63-65 inheritance, VB .NET, 41-53

better equality, 48-49 equality, 45-48 inheritance tree navigation, 51-53 method visibility, 49-51 shadowing

by accident, 41-42 further issues, 42-45

Initialization of Each Performance Counter Instance (code), 216

InnerException System. Exception prop­erty,371

installation debugging services without

installing, 314-315 HeartbeatMonitor, 475-477 remote debugging

full remote debugging installation, 471-472

native remote debugging instal­lation, 470-471

service installation code, 316-318 SQL server debugging components,

340-341 instances

performance counter instances, 215-216

relationship to counters and cate­gories, 213

sorting, 214 integer divisions, 59-60 Integrated Windows authentication

option, 282 interfaces. See also user interfaces

managed vs. unmanaged code, COM Interop, 322

sp_sdidebug as, 341 Web interface for remote control,

ServiceAdmin, 311 Internet Explorer

configuring for ASP. NET debugging, 286-287

page-level trace information and, 302 TimeServer Web service project and,

245,248 Interop. See COM Interop InteropDebug.sIn project. SeeVB .NET,

VB .NET applications using VB 6.0 components

Invoke method, 451 IsJitOptimizerDisabled flag, 79, 80, 81,

82 IsJitTrackingEnabled flag, 79, 80, 81, 82

J JIT compiler, 78-79, 80 JIT debugging

basics of, 85, 91-93 improving, 143 options, 127

Just-In-Time compiler. SeeJIT compiler

K keyboard code, 231 keywords

L

DEBUG keyword, 280-281 Friend keyword, 51 Overrides keyword, 50 Protected keyword, 50, 51 Shadows keyword

equality and, 45, 50 shadowing and, 42, 45

Lame Cat Equal to Any Other Cat? (code),46-47

languages. See also C#; C++; VB .NET, language surprises

multiple, and Visual Studio .NET debugger, 74

"The Last Bug", 337-338 leaky abstractions, 466 listings

ASP.NET debugging Dealing with a Page-Level Error

Using the Page_Error Event, 296

Dealing with an Application -Level Error Using an Application_Error Event, 298

Enabling Application -Level Tracing, 304

Enabling Page-Level Tracing at Design Time, 300

Enabling Page-Level Tracing at Runtime, 301

Loading the Trace Viewer Page, 304 Triggering a Page-Level Exception,

296 Triggering an Application-Level

Exception, 298

Triggering an Unhandled Exception, 294

Triggering and Catching an Exception Within a Procedure, 295

Using Web.config to Redirect an Exception to a Custom Page, 298

Using Web.config to Redirect Various Exception Types, 299

debugging tools CIL Produced by On Error Resume

Next (code), 161-163 CIL Produced by

Try ... Catch ... Finally (code), 164-165

Error Handling Comparison, 159-160

Modifying a String Manually, 167-168

Modifying a String Using StringBuilder, 168

error handling and exception man­agement

A Bad Way to "Improve" the System.lo.File.Move Method, 383

Catering to Every Possible Type of Unhandled Exception Situation, 412-413

Hiding an Implementation Detail with a Custom Exception, 385-386

Hiding an Implementation Detail with a Framework Exception, 384

Implementing a Realistic Unhandled Exception Filter, 407-409

Improving the System.lO.File.Move Method, 381-382

Overriding the Windows Form Built-in Unhandled Exception, 411

Probing the System.lO.File.Move Method, 379-380

Pseudo-Code for Try ... Catch ... Finally, 373

An Unhandled Exception Filter That Reports Exception Information, 402-404

A Usable UserLoadException Custom Exception, 385-386

UserLoadException Complete Custom Exception, 393-394

UserLoadException Custom Exception with Serialization, 389-390

Index

493

Index

494

listings (Continued) UserLoadException Custom

Exception with the UserID Property,390-391

multithreaded applications, debug­ging

The Account Class, 435-436 Adding SyncLock to Synchronize

Access to Shared Data, 431 The Bank Class, 432-433 Canceling the Calculation, 452 The Cashier Class, 434-435 Code to Launch the Calculation

Thread, 449-450 Completing the Calculation, 453 The CountCoordinator Class,

427-428 The CountWorker Class, 428-429 Displaying All User Threads

Within a Specified Process, 446-447

Displaying AlIWin32 Within a Specified Process, 444-445

A Hypothetical Transfer Method, 438

Performing the Accumulation Calculation, 450-451

A Thread-Safe Class for Reading and Writing Shared Data, 440-441

Trapping Any Calculation Thread Exception, 454

Updating the User Interface with Intermediate Calculation Results, 451-452

SQL server, debugging The Corrected Store Procedure, 350 Creating the Test Stored

Procedure,347-348 Creating the Test Tables, 347

tracing and instrumentation Creating and Using the

TraceSwitch Class, 204 Creating the Custom Trace Switch,

205-207 Creating the Performance

Category and Counters, 214-215

Custom Trace Listener for Recording Performance Data, 199-201

Determining If Debug Is Active, 212

Determining If Tracing Is Active, 194

Example of an Assertion Message, 191-192

Initialization of Each Performance Counter Instance, 216

Removing the Default Trace Listener, 195

Sending Trace Information to a Text File, 196-197

Sending Trace Information to the Application Event Log, 197-198

Sending Trace Information to the System Console, 195-196

Trace.WriteLineIf Performance Constraint, 190

Using the BooleanSwitch Class, 203

Using the Custom Trace Listener, 201

Using the Custom Trace Switch, 205

Using Trace.Assert, 190-191 Using Trace.Fail, 191 Using Trace.WriteLine, 189 UsingTrace.WriteLineIf,189 XML for Changing the Sensitivity

of Two Trace Switches, 209 The XML Produced by the Custom

Trace Listener, 202 XML to Add a Trace Listener at

Runtime, 208 XML to Deactivate a Boolean

Switch at Runtime, 209 XML to Redirect Assertion Failure

Messages at Runtime, 210 VB .NET, language surprises

Ambiguous Overloading, 34-35 Boxing Can Be Dangerous, 58 The C# Translation of Listing 2-18,

56 C# Translation of Listing 2-3, 37 C# Translation of Listing 2-5,

39-40 Corrected LameCat.Equals

Member, 48 Division By Zero, 59-61 Don't Forget to Override, 42 Double Trouble, 67 Is This Better?, 54 Lame Cat Equal to Any Other Cat?,

46-47 Member Overloading in VB .NET

vs. C#, 36 More Member Overloading in VB

.NET vs. C#, 38-39 Normal Inheritance Hierarchy,

43-44 See Double, 63-64 This Is Best, 54 Trouble When You Don't Cater

Properly to NaN, 64-65 Using Protection with Inheritance,

49-50

What is True Really?, 33 What the C# Developer (and

Compiler) Sees, 57 What the Compiler Sees, 54 What the Developer Sees, 54, 55 What the Developer Writes, 54, 55 What the VB .NET Compiler Sees,

56 Where Am I?, 51-52

VB.Classic debugging Type Library Information with

a ClassInterface Attribute of AutoDispatch, 334

Type Library Information with a ClassInterface Attribute of AutoDual, 334-335

Type Library Information with a Separately Implemented Interface, 336

VB .NET Can Combine COM Early Binding with Good COM Versioning, 335-336

VB .NET Component Code for use by a COM Client, 330

Web services, debugging The Bare-bones SoapMonitor

Custom SOAP Extension, 264 Binding the SoapMonitor

Extension to a Web Method, 269,274

Complete Soap Monitor Custom SOAP Extension, 266-268

Creating a Custom SoapException with Required Information, 257

CustomErrors Setting in TimeServer's Web.config, 262

The Debug Setting in TimeServer's Web.config, 244

Displaying the Custom Exception in the Client Application, 258-259

Exception Produced by the ThrowExceptionRaw Web Method,248

Hiding Exception Details for Nonlocal Users, 260-261

The ProcessMessage Method on a Client-Based SOAP Extension, 272-273

Setting Up Access to the SOAP Stream Memory Buffer, 265

The SoapMonitorAttribute Custom SOAP Attribute, 269

The ThrowExceptionCustom Web Method Throws a Custom Exception, 256

The TimeService Class, 245 Windows Forms controls, debugging

Controlling and Viewing Control Debug Events, 235-236

Implementing the Numeric TextBox Control, 234-235

Windows services, debugging Running a Windows Service As

a Standard.exe, 315 Updating ServiceAdmin's

Description During Installation, 317

Loading the Trace Viewer Page (code), 304

local method calls, vs. remote method calls, 459-460

LocalMonitor component, 477 local Only attribute, 304 Locals windows, 109-111 location breakpoints, 101-103 log utility, 166 logging

client SOAP logging, 27l-274 exception information, 376 logging exceptions and error han-

dling requirements, 368-369 logs, custom, for storing exceptions, 368 Lotus 1-2-3, and Excel bug, 30 The Lunch Game, 31

M macros, and Visual Studio .NET debug­

ger, 77 MagicSort, 215, 216 managed code

JIT debugging and, 91-92 vs. unmanaged, and COM Interop,

322 managed threads, terminating, 455-456 Mandelbugs, 238 Margarita bug, 30 Mark mode, defined, 96 Me windows

IDE debugging and, 113 using to examine objects, 225-226

mean time between bugs (MTBB), 6 mean time between failures (MTBF)

availability and, 10, 14 reliability and, 6-7

mean time to recovery (MTTR), 12, 14 Member Overloading in VB .NET vs. C#

(code), 36 memorable bugs, listed, 178-181 Memory windows

SQL debugging limitations and, 352 Visual Studio debugging and, 76, 77

message argument, 258 message semantics, 465-466 Message System.Exception property, 371 method calls, local vs. remote, 459-460 method visibility, 49-51

Index

495

Index

496

Microsoft. See also symbol server; Visual Studio .NET debugger

ASP.NET and, 277 Microsoft Message Queue (MSMQ), 13 Microsoft Windows

remote debugging and preparation, 468 restrictions, 473

symbols for Windows, management, 140-141

testing with fuzz, 307-308 Windows 2000

and gorilla testing, 308 remote debugging and, 473

Windows event log, for storing exceptions, 368

Windows NT 4.0 as requirement for SQL server

debugging, 339 VB.Classic debugging and, 321

Windows XP, and remote debugging, 473

Miller, Barton, 307 mode command, Cordbg, 155 Modules windows

application knowledge and, 76 debug symbols management and,

140 IDE debugging and, 115-116

mouse handling code, 231 MSMQ (Microsoft Message Queue), 13 Mssdi98.dll,341 MTBB (mean time between bugs), 6 MTBF (mean time between failures)

availability and, 10, 14 reliability and, 6-7

MTTR (mean time to recovery), 12, 14 multithreaded applications, debugging,

421-457 The 500-Mile E-mail bug, 456-457 basics of, 421-426

advantages, 423-424 difficulty of mUltihreading,

422-423 disadvantages, 425-426

lIS debugging, 282-283 multithreading in Windows Forms,

448-453 multithreading problems, 426-443

data races, 427-431 process deadlock, 431-439 process livelock, 439 thread starvation, 439-443

summary, 456 thread failure, 453-456

managed threads, terminating, 455-456

thread exceptions, 453-454 ThreadMonitor application, 443-448 uses of multithreading, 423-424

Murphy's Law, 28 Musical bug, 30

N names, choosing exception names, 387 NaN, 62, 63-65 native debugging

installation, 470-471 options, 128

native-only pipe transport protocol, and remote debugging, 468-469

native-only TCPIIp, and remote debug­ging, 468-469

navigation, inheritance tree navigation, 51-53

.NET Framework bug, 406 networks, and application failure, 5 nodes

child nodes, 258 Detail XML node, 258

Not a Number (NaN), 62, 63-65, 67 numbers

o

Division By Zero (code), 59-61 inexact, 67 as miscellaneous gotchas, VB .NET,

59-63 NaN and

floating-point issues, 67 Infinity properties, 63-65

throwing exceptions and, 59-63

obfuscated VB .NET code, 151 Off value, Custom Errors, 262 offset tables, and debug tracking

flag, 79 On Error Resume Next, and Ildasm,

159-160 On value, CustomErrors, 262 OnStart method, debugging, 315-316 Option Explicit, 128-129, 132 Option Strict, 128-129, 132 options, Visual Studio .NET debugger

E&C debugging options, 126-127 JIT options, 127 Native debugging options, 128 Project Default debugging options,

128-129 OutOfMemoryException, 386 Output windows, 96-67 overloading. See class member over-

loading overrides

Don't Forget to Override (code), 42 equality and, 45 overloads and, 38, 40, 41, 42

Overrides keyword, 50

p p-code,defined,84

page-level tracing, ASP.NET, 300-303 pageOutput attribute, 304 pair programming (PP), 27-28 parent exceptions, 387 performance counters, custom,

213-216 Performance Monitor (PerfMon)

basics of, 166-167 exception behavior and, 415--417 monitoring string performance with,

168-170 testing string performance, 167-170

permissions assemblies and, 172 assembly permissions, viewing. See

PermView investigating, 173-177 permission exceptions, 362-363 SQL server, debugging

remote debugging permissions, 242-243

sp_sdidebug and, 341-342 user account permissions, ASP.NET,

283-285 PermView, 171-177

basics of, 171-173 from the command line, 173 permissions, investigating, 173-177 within Visual Studio, 173

PP (pair programming), 27-28 process attach debugging

OnStart method and, 315 ServiceAdmin service debugging and,

312-314 process deadlock, 426, 431--439 process debugging

basics of, 85, 86-87 processes

attaching to, 87-89 breaking into, 89-90 detaching from, 90-91

process livelock, 426, 439 process recycling

with lIS 5.x, 279-280 with lIS 6.0, 280

production applications, debugging, 139-140

production debugging lIS and, 283 remote debugging and, 467

program state, and Windows Forms, 225-227

programming. See also listings pair programming, 27-28

Project Default debugging options, 128-129

project preparation, Visual Studio .NET project build configuration,

137-138 project build options, 133-134

project optimization options, 136-137

project start options, 134-136 Protected keyword, 50, 51 psychology of debugging developers. See

alsoE&C psychological factors, 25-28

Q Query Analyzer

direct debugging with, 346 requirements for SQL server debug­

ging, 340 question marks (?), and breakpoint

state, 107 queuing, software design for, 13-14 Quick sort algorithm, 149, 150 QuickSort instance, 215, 216 QuickWatch windows, 109

R RAIC (redundant array of inexpensive

components), 464 ReadData method, 441--442 reader locks, 441-442 ReaderWriterLock, 440 redundant array of inexpensive compo­

nents (RAIC), 464 reflexivity, as principle of equality, 48 Registers windows

SQL debugging limitations and, 352 Visual Studio debugging and, 76, 77

Release configuration, Visual Studio code optimization and, 147 described, 81 solution build configuration and, 132

reliability of applications, 4-10 measuring, 6-7 software reliability design, 7-9 software reliability, improving, 10 understanding, 4-5

remote debugging distributed systems, 466--467

full remote debugging installation, 471-472

installation, 469--470 native remote debugging instal­

lation, 470-471 preparation, 468-474 remote debugging restrictions,

472--474 remote servers, 286 remote SL servers permissions,

242-243 Visual Studio .NET debugger and, 76 Web services, 253

remote method calls, vs. local method calls, 459-460

RemoteMonitor, 478-479, 480 RemoteOnly value, CustomErrors, 262

Index

497

Index

498

report utility, 166 requestLimit attribute, 304 RequestMinimum permissions, 172 RequestOptional permissions, 172 RequestRefused permissions, 172 resource management and Windows

services debugging, 318 Robbins, John, 19 Running Documents windows, 118

S Salon magazine, 418 Schroedinbugs

described, 238 Twilight Zone bug as example of, 179

security Perm View and, 172 remote debugging restrictions and,

473 remote server debugging and, 286 SQL security, 353-355 user account permissions and,

ASP.NET, 285 See Double (code), 63-64 SEH (structured exception handling),

and exception management, 369,370

Selection sort algorithm, 149, 150 sequencing

latency interactions and, 17 sequencing bugs, 16

Server Explorer, and debugging stored procedures, 343

ServiceAdmin service debugging, 309-316

OnStart method debugging, 315-316 preparation, 310-311 process attach, 312-314 services, debugging without

installing, 314-315 Set Next Statement command, 352 shadowing, as VB .NET inheritance

issue, 41-45 Shadows keyword, 42, 50 shotgun debugging, and E&C, 19-22,23 simultaneous debugging

with IIS 5.x, 278 with IIS 6.0, 278

SOAP client, using for debugging, 248-252 vs. HTTPPOSTtransmission, 247 SOAP extensions, 264-268 SOAP messages, tracking, 263-274

client SOAP logging, 271-274 SoapMonitor attribute, building,

268-270 SoapMonitor, building, 264-268 summary of, 270-271

unhandled exceptions in XML Web services and, 414

SoapException, 254, 256, 257, 258 SoapMonitor

building, 264-268 logging at the client and, 271 Soap Monitor attribute, building,

268-270 SoapMonitorAttribute Custom SOAP

Attribute (code), 269 software

adding tracing to. See VB .NET tracing application failure and, 5 availability, 13-14 end users expectations for, 361 errors, and end users requirements,

363-364 reliability and, 7-9, 10 trusting, 69

solution preparation, Visual Studio .NET, 130-133

solution build configuration, 132-133 source files search paths, 130-131 symbol files search paths, 131

sort algorithms, testing, 149-150 SortCheck function, and finding bugs,

227 source files

locating, 84 source files search paths, 130-131

Source System.Exception property, 37l Source windows

debugging stored procedures from Visual Studio and, 343, 344

IDE debugging and, 97-99 sp_sdidebug, 341-342 SQL server, debugging, 339-357

application debugging, 346-351 from inside Visual Studio, 348-351 from outside Visual Studio, 351 setup, 346-348

code, how not to write, 355-357 direct debugging

with Query Analyzer, 346 with Visual Studio, 343-346

installation of components, 340-341 limitations of, 352-353 permissions and sp_sdidebug,

341-342 remote debugging permissions,

342-343 requirements, 339-340 SQL security, 353-355 summary, 355

SQL (Structured Query Language) advantages of, 339 SQL databases for storing exceptions,

368 SQL injection, defined, 354

SqlDataAdapter, 353 sqldbg.dll,341 sqldbreg2.exe, 341

SqlDebug project, 348-349 sqlle.dll,341 stack frames, defined, 227 StackOverfiowException, 386 StackTrace System. Exception property,

371 Start Action setting, 243, 290-291 state

breakpoint state, 106-107 defined, distributed systems, 464 distributed applications and, 464-465 program state, and Windows Forms,

225-227 static binding, defined, 51 stored procedures, and SQL server

debugging, 343-346 importance of, 339 sp_sdidebug,341-342 SQL debugging limitations and, 352

strategic debugging issues. See VB .NET strategic debugging issues

string performance, testing, 167-170 StringBuilder, modifying strings using,

168 structured exception handling (SEH),

and exception management, 369,370

Structured Query Language (SQL). See SQL (Structured Query Language)

support department requirements, 365-366

"swaying with the earthquake", 463 switches

boolean switch activation, 209 custom trace switches, creating,

203-204 trace switch activation, 209

symbol server, 142-143 symbols. See debug symbols symmetry, as principle of equality, 48 SyncLock statements, 436-437, 438 System. Diagnostics. Debugger-

StepthroughAttribute, 252 System.Diagnostics.EventLogTrace­

Listener, 197-198 System. Diagnostics. TextWriterTrace­

Listener class, 195-197 System. Diagnostics. Trace class, 188 System. Diagnostics. TraceListener class,

194 System.Exception class

exception management and, 370-372 properties, 371 Try ... Catch ... Finallyand

catching and rethrowing, 378 catching and swallowing, 376-378

systems. See also distributed systems, debugging

debugging complex, 14-18

T

building by contract, 15-16 possible solutions, 18 understanding communication

issues, 16-18

T&R (think and restart) debugging, 23-24 TargetSite System. Exception property,

371 test harness, 23 testing

code optimization, Visual Studio, 149-150

gorilla testing, 307-308 testing tools, 307 unit testing, with E&C, 21-22, 24

TextWriterTraceListener,195-197 TextWriterTraceListener class, 198-201 thawing threads, 447,448 think and restart (T&R) debugging,

23-24 Thread.Abort method, 455 ThreadAbortException, 386 ThreadGui application, 448-453, 454 ThreadMonitor application, 443-448 threads. See also multithreaded appli-

cations, debugging freezing, 447-448 thawing, 447, 448 thread failure, 453-456

managed threads, terminating, 455-456

thread exceptions, 453-454 thread starvation, 426, 439-443

Threads windows, 118 ThreadSynch program, 429-430 ThrowExceptionCustom Web Method

Throws a Custom Exception (code), 256

TIBCO Rendezvous (TIBRV), and queu­ing,13

time, units of, and MTBF, 7 TimeServerWeb service project

described, 243 TimeService Class (code), 245 TimeService class, public methods, 246 Tintin cartoon episode, 483 tools. See debugging tools Top 5 Bugs, 178-179 Trace class

Assert and Fail methods, 190-192 Debug class and, 212 methods, 188-192 tracing code and, 188

TRACEfiag trace activation and, 193 tracing code and, 188

TraceListener class trace listening and, 194 tracing information and, 188

Index

499

Index

500

traceMode attribute, 304 TraceSwitch class

level of tracing and, 188 trace control at compilation time

and, 202, 203-204 Trace.WriteLineIf Performance

Constraint (code), 190 tracing, and ASP.NET debugging,

300-306 application-level, 303-306 page-level, 300-303

tracing and instrumentation, 183-218 $500 million exception, 217-218 custom performance counters,

213-216 Debug class, 211-212 summary, 216 useful diagnostic information,

184-187 application development team,

185 application end users, 184 application support team, 184-185 design recommendations, 187 diagnostic categories, 185-187

VB .NET tracing. See VB .NET tracing Web services, and debugging, 274

tracking flag, 79 Transfer methods, 438 transitivity, as principle of equality, 48 transport protocols, and remote debug-

ging, 468-469 Triggering a Page-Level Exception

(code),296 Triggering an Application -Level

Exception (code), 298 Triggering an Unhandled Exception

(code),294 Triggering and Catching an Exception

Within a Procedure (code), 295

triggers, and SQL debugging limitations, 353

true value, in VB .NET, 33-34 Try block exceptions, 373-375 Try ... Catch ... Finally, 372-386

ASP.NET error handling and, 293, 295 basics of, 372-373 Ildasm and, 159-160 mechanics of, 373-375 SEH implementation and, 370 ThreadAbortException and, 455 using properly, 375-386

automatic propagation of exceptions, 375-376

catching and rethrowing System. Exception, 378

catching and swallowing System.Exception, 376-378

catching exceptions and throwing better exceptions, 384-385

catching exceptions and throwing custom exceptions, 385-386

catching exceptions and throwing new exceptions, 378-384

special exceptions, handling, 386 Twilight Zone bug, 179 Type Library Information with

a ClassInterface Attribute of AutoDispatch (code), 334

Type Library Information with a Class Interface Attribute of AutoDual (code), 334-335

Type Library Information with

U

a Separately Implemented Interface (code), 336

unhandled exceptions, 401-414 basics of, 401-405 catching and swallowing

System. Exception and, 377 defined,401 filter considerations, 405-407 filter when realistic, 407-409 in IDE debugging, 397, 399 in Windows Forms, 4lO-413 in XML Web services, 413-414

unit testing, with E&C, 21-22, 24 unmaintainable code, 355-357 unmanaged code

JIT debugging and, 92-93 vs. managed code, COM Interop, 322

URLScan, and lIS and DEBUG verb, 280-281

user accounts debugging preparation and, 242 user account permissions, ASP.NET,

283-285 user data, importance of saving, 364 user interfaces

single user interface, Visual Studio .NET,74-75

for sorting testing application, 221-222 for testing TimeServer Web service

methods, 249-250 ThreadGui, 448-453 ThreadMonitor application, 443-444 use of multithreading and, 423-424 VB 6.0, for testing VB .NET

components, 329 VB .NET, for testing VB 6.0

components, 323 users

end users expectations for software, 361 requirements for error handling,

363-364

user accounts debugging preparation and, 242 user account permissions,

ASP.NET, 283-285 utilities

V

alert utility, 166 chart utility, 166 dumpbin utility, 83-84 log utility, 166 report utility, 166

values. See also numbers CustomErrors values, 262 false value, and Double value, 66 message stage values, 264-265 TraceLevel enumeration values, 203 value of true, 33-34

van der Linden, Peter, 218 variables, problems with unequal, 65-66 VB.NET

vs. VB 6.0, and viewing public meth­ods, 327-328

VB 6.0 application using VB .NET component, 329-333

COM Interop application, 332-333 VB.Classic preparation, 331 VB .NET preparation, 330

VB .NET applications using VB 6.0 components, 323-329

COM Interop application, 326-327 tips, 327-328 VB 6.0 debugger, 328-329 VB.Classic preparation, 323-324 VB .NET preparation, 325-326

Windows services and, 309 VB .NET Can Combine COM Early

Binding with Good COM Versioning (code), 335-336

VB .NET Component Code for use by a COM Client (code), 330

VB .NET language compiler, 79-80 VB .NET, language surprises, 33-69

class member overloading, 34-40 ambiguous, 34-36 C# overload, 38-40 C# vs. VB .NET, 36-38

inheritance issues, 41-53 better equality, 48-49 equality, 45-48 inheritance and method visibility,

49-51 inheritance tree navigation, 51-53 shadowing by accident, 41-42 shadowing, further issues, 42-45

miscellaneous gotchas, 53-67 boxing conversions, 57-58 confusion between developer and

compiler, 53-55

confusion between VB .NET and C#,55-57

inexact numbers, 67 NaN trouble, 63-65 numbers as, 59-63 unequal variables, 65-66

summary, 68 trusting software, 69 value of true, 33-34

VB .NET strategic debugging issues, 3-31

application availability, 10-14 measuring, 12 software availability and, 13-14 understanding, 10-11

application reliability, 4-10 measuring, 6-7 software reliability and, 7-10 understanding, 4-5

debugging complex systems, 14-18 building by contract, 15-16 possible solutions, 18 understanding communication

issues, 16-18 debugging developer psychology. See

alsoE&C psychological factors, 25-28

folklore of debugging, types of bugs, 29-31

summary, 28 VB .NET tracing, 188-211

summary of, 211 trace activation, 193-194 trace control at compilation time,

202-207 BooleanSwitch class, using, 203 custom trace switches, creating,

204-207 TraceSwitch class, 203-204

trace control at runtime, 207-211 assertion redirection, 210 boolean switch activation, 209 trace listeners, adding and remov-

ing, 208 trace switch activation, 209

trace creation, 188-193 Assert and Fail methods, 190-192 assertions, 192-193 Write and writeLine methods,

188-189 Write If and Write Line If methods,

189-190 trace listening

custom trace listeners, creating, 198-202

DefaultTraceListener, 194-195 EventLogTraceListener, 197-198 TextWriterTraceListener, 195-197 TraceListener Class, 194

Index

501

Index

502

VB.Classic debugging, 321-338 COM versioning problems, overcom-

ing, 333-337 Evil Type Coercion, 134 managed vs. unmanaged, 322 summary, 337 "The Last Bug", 337-338 VB 5.0 vs. VB 6.0, 321 VB 6.0 application using VB .NET

component, 329-333 COM Interop application, 332-333 VB.Classic preparation, 331 VB .NET preparation, 330

VB .NET applications using VB 6.0 components, 323-329

COM Interop application, 326-327

tips, 327-328 VB 6.0 debugger, 328-329 VB.Classic preparation, 323-324 VB .NET preparation, 325-326

VB.Classic versions, 321 vs. Visual Studio .NET debugger, 73,

75,84,94 basic differences, 73, 75, 84 Immediate mode and, 94 Source windows and, 97-98

versioning overcoming COM versioning prob­

lems, 333-337 version requirements, SQL, 339-340

Visual Basic .NET. See VB .NET (several headings)

Visual Studio .NET debugger, 73-122 advantages of, 73-74 ASP.NET process debugging with, 292 attaching from, to ServiceAdmin pro-

cess, 313 debugging add-ins, 236-237 direct debugging with, 343-346 Ildasm and, 158 installing services and, 314 introduction to, 73-77

advanced breakpoints, 75-76, 103-106

application knowledge, 76 debugger automation, 77 distributed debugging, 75 low-level access, 76-77 multiple modes for, 75 remote debugging, 76 single user interface, 74-75

Modules windows, 76 Perm View, 173 remote debugging restrictions and,

473 SQLserver

application debugging, from inside and, 348-351

application debugging, from out­side and, 351

requirements for debugging, 340 summary, 120-121 three debugging modes, 84-93. See

also process debugging basics of, 84-85 IDE debugging, 85-86, 396-398,

398-399 JIT debugging, 91-93

vs. VB.Classic debugger basic differences, 73, 75, 84 Immediate mode and, 94 Source windows and, 97-98

Visual Studio debugger IDE, 93-118. See also breakpoints

Autos windows, 111-112 Call Stack windows, 114-115 Disassembly windows, 117-118 Immediate/Command windows,

93-96 Locals windows, 109-111 Me windows, 113 Modules windows, 115-116 Output windows, 96-67 QuickWatch windows, 109 Running Documents windows,

118 Source windows, 97-99 Threads windows, 118 Watch windows, 107-108

Visual Studio debugger IDE issues, 118-120

ChrCO),119-120 debugger single-stepping, 120 refusing to appear, 118-119

wish list for debugging, 121-122 workings of, 77-84. See also build

configurations basics of, 77-79 DebuggableAttribute class, 79 JIT compiler, 80 VB .NET compiler, 79-80 Visual Studio debugger, 80

Visual Studio .NET debugger, using, 123-151

active debugger process, setting, 138-139

CIL,debugging, 144-146 code optimization, 146-150

basics of, 146-148 as enemy, 148 test of, 149-150

debug symbols management, 140-143

symbol server, 142-143 symbols for applications, 140 symbols for framework SDK, 141 symbols for Windows, 140-141

E&C, coping without, 143-144 ]IT debugging, improving, 143 obfuscated VB .NET, 151 preparation, 123-130

W

Edit and Continue options, 126-127

general debugging options, 123-126

JIT options, 127 Native options, 128 other useful settings, 129-130 Project Default options, 128-129

production applications, debugging, 139-140

project preparation, 133-138 project build configuration,

137-138 project build options, 133-134 project optimization options,

136-137 project start options, 134-136

solution preparation, 130-133 solution build configuration,

l32-133 source files search paths, 130-131 symbol files search paths, 131

summary, 150

Watch windows debugging with, 228 IDE debugging and, 107-108

Web browsers, using for debugging, 244-248

Web services, debugging, 241-276 ASP.NET worker process, 242 client proxy, 252-253 deployed Web services, 253-254 preparation, 242-244 reconstructing failure, 274-276 remote Web services, 253 SOAP clients, using for debugging,

248-252 SOAP messages, tracking, 63-274

client SOAP logging, 271-274 SoapMonitor attribute, building,

268-270 SoapMonitor, building, 264-268 summary of, 270-271

summary, 274-275 tracing and instrumentation and,

274 Web browsers, using for debugging,

244-248 Web service failures, handling,

254-263 exception details, hiding, 260-263 exception flow, 254-255 exceptions, improving, 255-260

unhandled exceptions, trapping, 263

Web services, hype of, 241 Web sites

downloading from Debugging Tools for Windows

package (WinDbg), 142 fuzz testing tool, 308 Windows debug symbols, 142

for information The 500-Mile E-mail bug, 456 Salon magazine, 418 unmaintainable code article, 355 Windows debug symbols, 140

Web.config page redirection and, 299 setting CustomErrors in, 288-289 setting, XML, 287-288

When clause, 382 WinDbg

downloading, 142 for]IT debugging, 143

Windows. See Microsoft Windows windows

low-level access and, 76-77 problem of refusing to appear,

118-119 Visual Studio debugging windows

Autos windows, 111-112 Call Stack windows, 114-115 Disassembly windows, 76, 77,

ll7-118 Immediate/Command windows,

93-96 Locals windows, 109-111 Me windows, 113 Memory windows, 76, 77 Modules windows, 76,115-116 QuickWatch windows, 109 Registers windows, 76, 77 Running Documents windows,

118 Source windows, 97-99 Threads windows, 118 Watch windows, 107-108

Visual Studio .NET debugging win­dows

Command window, 93-94, 95-96 Immediate window, 93-95

window painting code, 229-230 Windows event log, for storing

exceptions, 368 Windows Forms, 221-239

ASP.NET and, 277 Bug Dictionary, 238-239 controls, debugging, 233-236 debugging basics of, 221-231

breaking into applications, 223 building applications, 222

Index

503

Index

504

Windows Forms (Continued) finding bugs, 227-229 hitting breakpoints, 224-225 program state, examining,

225-227 tricky debugging situations,

229-231 multithreading in, 448-453 other Windows Forms applications,

debugging, 232-237 class libraries, 232-233 control designers, 237 Visual Studio add-ins, 236-237 Windows Forms controls, 233-236

summary, 237 unhandled exceptions in, 410-413

Windows services, debugging, 309-320 IfIn Doubt, Ask, 319-320 installation issues, 316-318 resource management and, 318 ServiceAdmin service debugging,

309-316 OnStart method debugging,

315-316 preparation, 310-311 process attach, 312-314 services, debugging without

installing, 314-315 summary, 318

Windows Terminal Server (WTS), debug-ging trick using, 230

wire protocol, 15 wish list for debugging, 121-122 worker process, ASP.NET

isolation mode, 278 process recycling with IIS 5.x and, 279 process recycling with IIS 6.0 and, 280

Web services, debugging and, 242 wrappers, for File.Move, 381 Write and write Line methods, 188-189 WriteData method, 442 WriteIf and WriteLineIf methods, and

trace creation, 189-190 writer locks, acquiring, 442-443 writer-reader problems, 440 wt command, Cordbg, 155

X XML

custom trace listener and, 202 debug XML attribute, 244 Detail XML node, 258 formats to control tracing

adding and removing trace listen-ers and, 208

assertion redirection and, 210 boolean switch activation and, 209 trace switch activation and, 209

Web services, unhandled exceptions in, 413-414

Web.config, 287-288 XML configuration file, and

TimeServer, 244 XML for Changing the Sensitivity ofTwo

Trace Switches (code), 209 XML Produced by the Custom Trace

Listener (code), 202 XML to Add a Trace Listener at Runtime

(code), 208 XML to Deactivate a Boolean Switch at

Runtime (code), 209

Z zero, division by, 59-63