Home » Development » Collect dump files with DebugDiag for a custom exception

Collect dump files with DebugDiag for a custom exception

Let’s say your application throws exceptions with custom error messages when a specific condition occurs. This exception will show up in Event Viewer. However, the information in the event log may not be sufficient to troubleshoot the issue. You may need a full userdump to find out what’s going on in the background.

If you want to collect a dump file automatically for the custom exceptions, follow the steps below.

Custom exceptions

For the simple test application I created, I used the following lines to throw an exception. This Visual Basic application simply threw “Cannot determine the proforma” error when the user clicked Button1.

Public Class _Default
    Inherits Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Throw New Exception("Cannot determine the proforma")
    End Sub
End Class

When I clicked the button, the event log below showed up in Event Viewer.

Log Name:      Application
Source:        ASP.NET 4.0.30319.0
Event ID:      1309
Task Category: Web Event
Level:         Warning
Keywords:      Classic
Description:
Event code: 3005 
Event message: An unhandled exception has occurred. 

Process information: 
    Process ID: 6476 
    Process name: w3wp.exe 
 
Exception information: 
    Exception type: Exception 
    Exception message: Cannot determine the proforma
   at Test.Default.Button1_Click() 
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain

Set up DebugDiag to create dumps for custom exceptions

Follow the steps below to create a DebugDiag rule to capture a dump file automatically when the exception occurs again next time:

  1. Open DebugDiag Collection
  2. Click “Add Rule”
  3. Select “Crash”. Click “Next”
  4. Select “All IIS/COM+ related processes” and click “Next”
  5. Click “Exceptions”
  6. Click “Add Exception”. In this window:
    • Select “CLR Exception” on the left side
    • On the right side, add a part of your exception message into “Exception Message Includes” field. Do not use quotation marks (Screenshot for a sample rule is below)
    • Select “Full Userdump” from the “Action Type” list
    • Click OK
  7. Click “Save & Close”
  8. Click “Next” and follow the rest of the instructions to complete the rule creation
Configure DebugDiag to create dumps for custom exceptions

If the DebugDiag throws the error “System.Exception: AutoUpdate failed”, check out the solution in this post: DebugDiag error “System.Exception: AutoUpdate failed”

Ned Sahin

Blogger for 20 years. Former Microsoft Engineer. Author of six books. I love creating helpful content and sharing with the world. Reach me out for any questions or feedback.

Leave a Comment