Extended Properties when logging an exception

Topics: Exception Handling Application Block, Logging Application Block
Nov 13, 2007 at 6:47 PM
How do I get access to the extended properties of an exception?

This works very well to add extended properties to a LogEntry object:

Dim dictionary As New Dictionary(Of String, Object)()
Dim provider As DebugInformationProvider = New DebugInformationProvider

Dim logEntry As LogEntry = New LogEntry()
logEntry.Message = "Logged with context specific information"
logEntry.ExtendedProperties = dictionary
logEntry.Categories.Add("Inner Process")


But I want to do the exact same thing for my exception, below:

Throw New Exception("my test exception")
Catch ex As Exception
Dim rethrow As Boolean = ExceptionPolicy.HandleException(ex, "Log Only Policy")
If (rethrow) Then
End If
End Try

**In the end I want to pump out the full stack trace when an exception is thrown. Any articles or work around for this?

Nov 15, 2007 at 8:22 PM
You can create a new exception, make the actual excecption an inner exception - and then attach your Dictionary<> to the .Data property of your new created exception, and use that in the method.