FormatterType

Topics: Exception Handling Application Block, General discussion
Feb 26, 2007 at 12:13 PM
hi...
I am using XmlExceptionFormatterType, to log the exceptions in the event log, now, how can i get this xml exception in my application?

thank you...
Feb 26, 2007 at 2:17 PM
Are you asking how you catch Exceptions in an application? You typically would use a try/catch block to catch an exception and then based on your logging policy decide if you want to log and/or rethrow it.

I recommend you check the Enterprise Library Documentation for 2.0 which has great examples on how you use the Exception Handling Block to log exceptions under

Exception Handling Application Block -> Developing Using the Exception Handling Application Block -> Key Scenarios -> Logging an Exception.

Here is a snippet of code pulled from the documentation:

try
{
  // Run code.
}
catch(Exception ex)
{
  bool rethrow = ExceptionPolicy.HandleException(ex, "Logging Policy");
  if (rethrow)
    throw;
}

Regards,

Dave

________________________

David Hayden
Microsoft MVP C#
Feb 26, 2007 at 5:30 PM
hi..
I know how to use the exception block, what i ment is, i configure the exception policies to log the error in event log, so, the error that logged in the event log is in: xml format, because i configured the FormatterType to XmlExceptionFormatterType, and i wanted to know how can i get this xml exception(the string of this exception that logged in xml format), i want to assign it to XmlDocument, and print it to the screen??

thank you...