<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" ><channel><title>Scott Elkin &#187; Enterprise Library</title> <atom:link href="http://scottelkin.com/category/programming/enterprise-library/feed/" rel="self" type="application/rss+xml" /><link>http://scottelkin.com</link> <description>Tech, Love, Life</description> <lastBuildDate>Thu, 07 Apr 2011 23:02:52 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Add Additional Information to Your Exceptions</title><link>http://scottelkin.com/programming/aspnet-20/add-additional-information-to-your-exceptions/</link> <comments>http://scottelkin.com/programming/aspnet-20/add-additional-information-to-your-exceptions/#comments</comments> <pubDate>Wed, 19 Jul 2006 07:37:00 +0000</pubDate> <dc:creator>Scott</dc:creator> <category><![CDATA[ASP.NET 2.0]]></category> <category><![CDATA[C#]]></category> <category><![CDATA[Enterprise Library]]></category> <category><![CDATA[Exceptions]]></category> <category><![CDATA[Programming]]></category><guid isPermaLink="false">/archive/2006/07/19/Add-Additional-Information-to-Your-Exceptions.aspx</guid> <description><![CDATA[When Enterprise Library was called Microsoft Application Blocks, if you wanted to log an Exception, you would write (assuming &#8220;ex&#8221; 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 [...]No related posts.]]></description> <content:encoded><![CDATA[<p>When Enterprise Library was called Microsoft Application Blocks, if you wanted to log an Exception, you would write (assuming &#8220;ex&#8221; is an Exception):</p><pre><code>ExceptionManager.Publish(ex)</code></pre><p>And if you wanted to log some extended properties you could do something like this:</p><pre><code>NameValueCollection customerInfo = new NameValueCollection();
customerInfo.Add("name","scott");
customerInfo.Add("email","blah@blah.com");
ExceptionManager.Publish(ex,customerInfo);
</code></pre><p>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:</p><pre><code>ExceptionPolicy.HandleException(ex, "General Policy");
</code></pre><p>where “General Policy” is the name of the Exception Policy in the config file telling the Block what to do with the exception.</p><p>Looking in the config file, I noticed a formatter template with the following at the tail end of the template attribute, “…Extended Properties: {dictionary({key} &#8211; {value} )}&#8221;.  The formatter template is used to format the exception that is about to be logged somewhere.  Looking through the code for where it loops through this Dictionary, I noticed it accessing an IDictionary of <a href="http://msdn2.microsoft.com/en-us/library/system.exception.data.aspx">Exception.Data</a>.  Exception.Data?  Where did that come from?</p><p>Data is a new .NET framework 2.0 property of the Exception class to allow you to add any user-defined information about the exception.  Nothing more to it:  Just a simple name/value dictionary for your enjoyment.  As if you couldn’t figure it out, my new code would look like:</p><pre><code>ex.Data.Add("name","scott");
ex.Data.Add("email","blah@blah.com");
ExceptionPolicy.HandleException(ex, "General Policy");</code></pre><p>And as long as you use the default formatter, it will log this data at the end of the FormattedException field.</p><p>No related posts.</p>]]></content:encoded> <wfw:commentRss>http://scottelkin.com/programming/aspnet-20/add-additional-information-to-your-exceptions/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Exception Handling Block Error</title><link>http://scottelkin.com/programming/enterprise-library/exception-handling-block-error/</link> <comments>http://scottelkin.com/programming/enterprise-library/exception-handling-block-error/#comments</comments> <pubDate>Sun, 13 Mar 2005 23:39:00 +0000</pubDate> <dc:creator>Scott</dc:creator> <category><![CDATA[Enterprise Library]]></category> <category><![CDATA[Programming]]></category><guid isPermaLink="false">/archive/2005/03/13/Exception-Handling-Block-Error.aspx</guid> <description><![CDATA[Ran into the error: There were no types found in the assembly &#39;MyAssembly&#39; that implement or inherit from the base type &#39;System.Exception&#39;. when trying to add a custom Exception Policy in the new Enterprise Library Exception Handling Application Block. After finding Jason&#39;s Post I saw the relevance to my problem. I copied all my references [...]No related posts.]]></description> <content:encoded><![CDATA[<p>Ran into the error:</p><pre>There were no types found in the assembly &#39;MyAssembly&#39; that implement or inherit from the base type &#39;System.Exception&#39;.
</pre><p>when trying to add a custom Exception Policy in the new Enterprise Library Exception Handling Application Block. After finding <a href="http://www.visualjason.net/PermaLink.aspx?guid=df4163e8-61f4-411b-8c32-303cc3435cf2" target="_blank" title="http://www.visualjason.net/PermaLink.aspx?guid=df4163e8-61f4-411b-8c32-303cc3435cf2">Jason&#39;s Post</a> I saw the relevance to my problem.</p><p>I copied all my references in the Enterprise Library bin directory, and voila&#8230;</p><p>No related posts.</p>]]></content:encoded> <wfw:commentRss>http://scottelkin.com/programming/enterprise-library/exception-handling-block-error/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)

Served from: scottelkin.com @ 2012-02-09 10:33:06 -->
