Colin Bowern

... more of the usual bool

  Home  |   Contact  |   Syndication    |   Login
  23 Posts | 0 Stories | 13 Comments | 24 Trackbacks

News

Archives

Post Categories

I really liked the original exception management block put out by Microsoft.  The reason is because it included all the information relating to an exception - not just the Message property.  It made production debugging a breeze.  Now with ASP.NET 2.0 and Health Monitoring something similar has been created but it doesn't quite cover all the details.  I first ran into this in an application where I had created a custom exception, ArgumentFormatException, and passed along two additional properties.  After puttering through the underpinnings of the Health Monitoring feature I noticed that the exception information is captured using the Message property of the Exception by the EventLogWebProvider class.  In order to beef up the data returned by my exception I put in a Message property which overrides the base version:

  127         public override string Message

  128         {

  129             get

  130             {

  131                 StringBuilder messageText = new StringBuilder(base.Message);

  132 

  133                 if ((this.m_ExpectedFormat != null) && (this.m_ExpectedFormat.Length != 0))

  134                 {

  135                     messageText.Append(Environment.NewLine);

  136                     messageText.AppendFormat(CultureInfo.CurrentCulture, StringResources.ParameterExpectedFormat, m_ExpectedFormat);

  137                 }

  138 

  139                 if ((this.m_ActualValue != null) && (this.m_ActualValue.Length != 0))

  140                 {

  141                     messageText.Append(Environment.NewLine);

  142                     messageText.AppendFormat(CultureInfo.CurrentCulture, StringResources.ParameterActualValue, m_ActualValue);

  143                 }

  144 

  145                 return messageText.ToString();

  146             }

  147         }

After re-running the tests voila I now have more detailed exceptions.

Exception information:

Exception type: ArgumentFormatException

Exception message: The variable does not match the expected format.

Parameter name: emailAddress

Expected Format: ^([a-zA-Z0-9_\-\.']+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$

Actual Value: xxxx

posted on Saturday, January 21, 2006 1:34 AM

Feedback

# re: Exception Detail and Health Monitoring in ASP.NET 2.0 3/30/2007 8:01 AM Michael
I am having a issue with Health Monitoring I am getting a index is out of range on a page and routine. But I need the actual line number that this is occuring, because is a large routine and I can't reproduce on my end. Is there a way to get the actual line number or variable name etc.
Thanks


# re: Exception Detail and Health Monitoring in ASP.NET 2.0 3/30/2007 12:01 PM Colin Bowern
You'll need a stack trace and debug symbols (pdb files) installed along side the assemblies to facilitate variable names and line numbers.

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: