Table of Contents
About the Author
Part I – Overview
Part I Introduces the reader to the basic concepts required to efficiently debug .NET applications using the Debugging Tools for Windows package.
1. Introduction to the Tools
A brief introduction to the tools used throughout the book including basic usage scenarios, download locations, and installation instructions. Amongst the tools covered are:
Debugging Tools for Windows
.NET 2.0 redist/SDK
Reflector for .NET
Managed Debugging Assistants
2. CLR Fundamentals
This chapter discusses the core fundamentals of the CLR. The chapter begins with a high level overview of the major runtime components and subsequently drills down into the details and covers topics such as:
• CLR and the Windows Loader. Discusses how .NET applications are natively supported using the PE file format.
• Application domains (system, shared, default, custom) as well as loader heaps etc.
• Assembly overview
• Assembly manifest
• Type metadata
• And more…
3. Basic Debugging Tasks
Chapter 3 give hands on examples of the basic .NET debugging tasks such as:
Display stack traces
Display local variables
Dumping heap based objects
.NET exception model and how to analyze in the debuggers
Basics of postmortem debugging
Part II – Applied Debugging
Part II is a practical approach to debugging common .NET problems encountered in the development process. Each chapter is dedicated to a specific CLR component and/or technology and begins by detailing the inner workings of that component. Subsequently, a number of common problems related to the specific technologies are discussed and how the debuggers and tools can be used for root cause analysis.
4. Assembly Loader
The complexity of .NET applications can range from simple command line applications to complex multi-process/multi machine server applications with a large number of assemblies living in harmony. In order to efficiently debug problems in .NET applications one much be careful to understand the dependencies of .NET assemblies. This chapter takes a look at how the CLR assembly loader does its work and common problems surrounding that area.
5. Managed Heap and Garbage Collection
While .NET developers can enjoy the luxury of automatic memory management care must still be taken to avoid costly mistakes. The highly sophisticated CLR garbage collector is an automatic memory manager that allows developers to focus less on memory management and more on application logic. Even though the CLR manages memory for the developer, care must be taken to avoid pitfalls that can wreak havoc in your applications. In this chapter we look at how the garbage collector works, how to peek into the internals of the garbage collector and some common programming mistakes related to automatic garbage collection (non memory resources, memory fragmentation, finalizer problems etc).
A multithreaded environment allows for a great deal of flexibility and efficiency. With this flexibility comes a lot of complexity in the form of thread management. To avoid costly mistakes in your application, care must be taken to ensure that threads perform their work in an orchestrated fashion. This chapter introduces the synchronization primitives available in .NET and discusses how the debuggers and tools can be used to debug common thread synchronization problems. Scenarios such as deadlocks, lock contentions, sync blocks, thin locks and thread pool problems are discussed.
.NET relies heavily on underlying Windows components. In
order to invoke the native Windows components the CLR exposes two primary
methods of interoperability:
1. Platform Invocation
2. COM Interoperability
Since the.NET and Win32 programming models are often very different idiosyncrasies often lead to hard to track down problems. In this chapter we look at some very common mistakes done when working in the Interoperability layer and how to use the debuggers and tools to troubleshoot the problems.
Part III – Advanced Topics
8. Postmortem Debugging
Quite often it’s not feasible to expect full access to a failing machine so that a problem can be debugged. Bugs that surface on production machines on customer sites are rarely available for debugging. This chapter outlines the mechanisms for debugging a problem without access to the physical machine. Topics discussed include the basics of crash dumps, generating crash dumps, analyzing crash dumps etc.
9. Power Tools
Introduces the reader to power tools such as Debugging via Powershell , IISDiag and more.
10. CLR 4.0
With the imminent release of CLR 4.0, this chapter takes an abbreviated tour of the CLR 4.0 enhancements. The chapter is structured so that each topic in previous chapters of the book are covered from a CLR 4.0 perspective.