Exception Handling Block in ASP.NET to Send Email

Topics: Exception Handling Application Block, Logging Application Block
Jul 6, 2007 at 10:47 PM
I don't get it. I configured my exception handling block and logging block using the config tool. I created a page that will generate an exception. In my global.asax I have the following:

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim ex as Exception = Server.GetLastError().GetBaseException()
ExceptionPolicy.HandleException(ex, "Global Policy")
End Sub

This line ----> ExceptionPolicy.HandleException(ex, "Global Policy") Generates the following error:

Unable to cast object of type 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings' to type 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings'.

WTF??? Unable to cast something to what it already is?????? Really, this was just supposed to be a very simple example. Why the F is it such a huge pain??? How do I get it to work??

Any help is greatly appreciated!

Thanks!

Jul 7, 2007 at 12:06 AM
Edited Jul 7, 2007 at 2:42 AM
Hi,

You're probably mixing two versions of the enterprise library assemblies. Make sure you don't have different versions of the assemblies in your project (e.g. the signed binaries and the source code) and that the types in your configuration file match your references (i.e. don't use the signed tool to edit the configuration for a project with references to the unsigned version).
If you could provide a stack trace and additional exception data, as well as the version of the enterprise library you're using, it will be easier to help you.

Fernando