Content

Enterprise Library Category

Add Additional Information to Your Exceptions

19 Jul

+ 0

When Enterprise Library was called Microsoft Application Blocks, if you wanted to log an Exception, you would write (assuming “ex” is an Exception):

ExceptionManager.Publish(ex)

And if you wanted to log some extended properties you could do something like this:

NameValueCollection customerInfo = new NameValueCollection();
customerInfo.Add("name","scott");
customerInfo.Add("email","blah@blah.com");
ExceptionManager.Publish(ex,customerInfo);

Now that I am upgrading all legacy code to Enterprise Library 2006 for .NET 2.0, I couldn’t find a way to do this since the only way to log an error is:

ExceptionPolicy.HandleException(ex, "General Policy");

where “General Policy” is the name of the Exception Policy in the config file telling the Block what to do with the exception.

  Leave Comment, 0 Comments

Exception Handling Block Error

13 Mar

+ 2

Ran into the error:

There were no types found in the assembly 'MyAssembly' that implement or inherit from the base type 'System.Exception'.

when trying to add a custom Exception Policy in the new Enterprise Library Exception Handling Application Block. After finding Jason's Post I saw the relevance to my problem.

I copied all my references in the Enterprise Library bin directory, and voila…

  Leave Comment, 2 Comments