Jaa


Production Debugging for .NET Framework Applications

Retired Content
This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

 

patterns & practices Developer Center

Related Links

patterns and practices Index

Application Architecture for .NET: Designing Applications and Services

Roadmap

Aaron Barth, Jackie Richards
Program Manager: Edward Jezierski

Microsoft Corporation

November 2002

The patterns & practices team has decided to archive this content to allow us to streamline our latest content offerings on our main site and keep it focused on the newest, most relevant content. However, we will continue to make this content available because it is still of interest to some of our users.
We offer this content as-is, without warranty that it is still technically accurate as some of the material is undoubtedly outdated. Note that the content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Summary: This guide provides debugging guidance for developers debugging .NET Web applications. It discusses the processes for debugging in a production environment.

Introduction

Every developer or support engineer debugs applications at some stage in his or her career, yet debugging is often viewed as an arcane and difficult topic. While it is often difficult to determine why an application is hanging, leaking memory, or crashing, there are techniques you can apply to make the debugging process more productive and efficient. The Production Debugging for .NET Framework Applications guide aims to equip you with the mindset, tools, and techniques that will help you successfully identify and resolve common application debugging.

The techniques presented here are not simplified classroom exercises. They are based on the experience of both Microsoft customers and Microsoft internal development teams. These techniques represent proven, best-practice approaches to debugging a variety of issues.

This guide presents walkthroughs of three scenarios that ASP.NET applications may encounter when running in production environments: memory consumption, contention (also known as "deadlock"), and unexpected server crashes. How operators detect symptoms of these issues and determine overall system health is not within the scope of the guide.

These scenarios concentrate on debugging Microsoft® .NET Framework applications in a production environment, focusing on low-level details such as thread states and memory allocations. However, the thought processes and techniques discussed will help you understand debugging on a much broader scale. This document helps you learn how to think about debugging in a general sense, and equips you with the mindset to successfully approach unknown and unforeseen debugging situations in the future.

Although the example scenarios target ASP.NET and the Visual C#™ development tool, the thought processes and techniques discussed are common across all .NET technologies and languages, and problems encountered are common themes. The scenarios also introduce the tools that Microsoft provides for the Microsoft Windows® operating system and .NET debugging, including the use of WinDbg, Core Debugger (CDB), and debugger extension DLLs for displaying managed call stacks and object data.

Who Should Read This Guide

This guide provides information on how to debug applications running in the .NET environment. It is aimed at developers and support engineers who have existing debugging skills and who want to extend those skills into the .NET environment. It can also be of use to others who wish to gain an appreciation of how .NET works and the issues involved in debugging.

What You Must Know

To use this guide, you should have the following:

  • Experience developing and debugging applications in the Microsoft .NET environment. However, extensive programming experience is not required.
  • Experience using tools such as the Microsoft Visual Studio® .NET development system; you may also have experience with other Microsoft debugging tools, such as WinDbg and CorDbg.
  • An understanding of Windows operations, such as memory allocation and deallocation, processes, and threads.

Download

Click here to download this guide in PDF format.

Click here to download the Debugging Walkthrough msi.

Click here to download the Debugging Toolset.

What's in This Guide

The Production Debugging for .NET Framework Applications guide**is designed to provide the information that you need to approach debugging .NET applications.

Production Debugging for .Net Framework Applications consists of four chapters and an appendix*.* Although reading the entire guide gives you a more complete understanding of debugging in .NET, you are encouraged to read the chapters that most closely relate to your debugging scenarios. The following paragraphs summarize the contents of the remaining chapters in this guide.

Chapter 1: Introduction to Production Debugging for .NET Framework Applications

Chapter 1 provides a conceptual frame for the debugging process and exposes the decisions that must be made with regards to the environment (including IIS) and tools.

Chapter 2: Debugging Memory Problems

This chapter describes how to approach debugging memory consumption problems that users may experience when using ASP.NET applications. Topics include how memory is managed in .NET and how the garbage collector reclaims unused memory. A walkthrough then shows how to debug a memory consumption scenario.

The first scenario shows how to debug memory allocation problems, including how to find out how much memory is being allocated by an ASP.NET process and where in the process it is being allocated.

Chapter 3: Debugging Contention Problems

This chapter shows how to approach debugging an application that hangs or exhibits symptoms of resource contention. An ASP.NET application is used to demonstrate what happens when threads contend for a shared resource and how to diagnose and debug memory allocation problems in .NET Framework applications.

The second scenario illustrates resource contention, also known as deadlock. This scenario shows how threads within an ASP.NET application can hang if they are contending for a shared resource.

Chapter 4: Debugging Unexpected Process Termination

This chapter shows how to debug applications that crash unexpectedly. Although many factors can cause applications to crash, the scenario uses a COM Interop example to demonstrate unexpected process termination.

The final scenario shows how to diagnose and debug Server Application Unavailable errors. The scenario shows how these errors can arise when using COM components in ASP.NET applications.

Appendix

This appendix contains the following:

  • Thread state values. This contains a list of possible thread states and their descriptions.
  • Application code. This lists the Visual C# code for the three ASP.NET applications used in the scenarios.
  • Debugging with CorDbg. This shows you how to use CorDbg as an alternative to WinDbg for debugging managed code. It is an addendum to Chapter 3, "Debugging Contention Problems."
  • Exploring further. This contains a list of articles to read for more information.

Feedback and Support

  • Questions? Comments? Suggestions? For feedback on the Production Debugging for .NET Framework Applications guide, please e-mail us at devfdbck@microsoft.com.
  • The Application Blocks for .NET components and guides are designed to jumpstart development of .NET distributed applications. The sample code and guidance is provided "as-is." Support is available through Microsoft Product Support for a fee.
  • A newsgroup has also been created to assist you with the Application Blocks for .NET components and guides. Use this newsgroup to consult with your counterparts, peers, and Microsoft Support Professionals in an online, open forum.
  • Everyone else benefits from your questions and comments, and our development team is monitoring the newsgroup on a daily basis:
    Newsgroup: Web-Based Reader
    https://msdn.microsoft.com/newsgroups/loadframes.asp?icp=msdn&slcid=us&newsgroup=microsoft.public.dotnet.distributed_apps
  • Newsgroup: NNTP Reader

Collaborators

Many thanks to the following contributors and reviewers: Jim Miller (COM+), Jim Hogg, Matt Neerincx, Dean Cron, Jesse Campbell, Nathan Enright, James Hanners, Pavel Lebedynskiy, Wade Mascia, J.D. Meier.

Thanks, also, to the content team: Lin Joyner (Content Master), Ed Lafferty, Sharon Smith, Kathleen Hartman, Dan Thompson, Mohammad Al-Sabt, Sameer Tarey (Infosys Technologies Ltd), and Ashish Babbar (Infosys Technologies Ltd).

patterns & practices Developer Center

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

© Microsoft Corporation. All rights reserved.