<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Arogl Darthu's Blog - WCF</title>
    <link>http://blog.arogldarthu.nl/</link>
    <description>profound astoundment</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.3.1 - http://www.s9y.org/</generator>
    <pubDate>Fri, 27 Mar 2009 18:43:30 GMT</pubDate>

    <image>
        <url>http://blog.arogldarthu.nl/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: Arogl Darthu's Blog - WCF - profound astoundment</title>
        <link>http://blog.arogldarthu.nl/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Wcf Exception Shielding - Unexpected FaultContracts</title>
    <link>http://blog.arogldarthu.nl/archives/12-Wcf-Exception-Shielding-Unexpected-FaultContracts.html</link>
            <category>WCF</category>
    
    <comments>http://blog.arogldarthu.nl/archives/12-Wcf-Exception-Shielding-Unexpected-FaultContracts.html#comments</comments>
    <wfw:comment>http://blog.arogldarthu.nl/wfwcomment.php?cid=12</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blog.arogldarthu.nl/rss.php?version=2.0&amp;type=comments&amp;cid=12</wfw:commentRss>
    

    <author>nospam@example.com (Twan Jacobs)</author>
    <content:encoded>
    So you&#039;ve got Wcf Exception Shielding in place. All is well and the Enterprise Library Exception Handling Application Block takes care of those nasty exception details that you don&#039;t want your site visitors to know about... But have you ever had the urge to do more than just property mapping between exceptions and FaultContract? I know I have &lt;img src=&quot;http://blog.arogldarthu.nl/templates/default/img/emoticons/wink.png&quot; alt=&quot;;-)&quot; style=&quot;display: inline; vertical-align: bottom;&quot; class=&quot;emoticon&quot; /&gt;&lt;br /&gt;
&lt;br /&gt;
There is a way to do this and it is actually quite simple to realize. You just have to create your own custom IExceptionHandler. But let&#039;s start with a bit of configuration. By default you would have an Exception Policy named &quot;WCF Exception Shielding&quot;. Like so:&lt;br /&gt;
&lt;div class=&quot;xml&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;exceptionHandling&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;exceptionPolicies&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;add&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;WCF Exception Shielding&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/exceptionPolicies&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/exceptionHandling&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
This policy handles specific Exception types and for each of those it will pass the exception through a chain of IExceptionHandlers. The last of these would normally be Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractExceptionHandler. For instance:&lt;br /&gt;
&lt;div class=&quot;xml&quot; style=&quot;text-align: left&quot;&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;exceptionTypes&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;add&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;System.DivideByZeroException, mscorlib&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt; &amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #000066;&quot;&gt;postHandlingAction&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;ThrowNewException&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;DivideByZeroException&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;exceptionHandlers&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;add&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;exceptionMessage&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Dividing by zero is not allowed.&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #000066;&quot;&gt;faultContractType&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;DivideByZeroFault, MyDll&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #000066;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;FaultContractExceptionHandler, ExceptionHandling.WCF&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;color: #009900;&quot;&gt; &amp;#160; &amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Fault Contract Exception Handler&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;mappings&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;add&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;source&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Guid&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Id&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;add&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;source&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Message&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Message&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &amp;#160;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/mappings&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/add&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &amp;#160;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/exceptionHandlers&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160; &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/add&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;/exceptionTypes&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;
Now what if your FaultContract would need additional data, that you can&#039;t just map from the Exception properties? For example:&lt;br /&gt;
- you might need the Message property of the InnerException;&lt;br /&gt;
- you need data that was logged to a database when the original exception got thrown.&lt;br /&gt;
&lt;br /&gt;
To make this possible, just create your own IExceptionHandler that will be used instead of the provided FaultContractExceptionHandler. There are two things to keep in mind when you do this. First of all you should always set the &lt;strong&gt;postHandlingAction&lt;/strong&gt; to &lt;strong&gt;ThrowNewException&lt;/strong&gt;. Second, you should let your IExceptionHandler return a specific Exception type: &lt;strong&gt;FaultContractWrapperException&lt;/strong&gt;. &lt;br /&gt;&lt;a href=&quot;http://blog.arogldarthu.nl/archives/12-Wcf-Exception-Shielding-Unexpected-FaultContracts.html#extended&quot;&gt;Continue reading &quot;Wcf Exception Shielding - Unexpected FaultContracts&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Fri, 27 Mar 2009 15:21:54 +0000</pubDate>
    <guid isPermaLink="false">http://blog.arogldarthu.nl/archives/12-guid.html</guid>
    
</item>
<item>
    <title>Proxy's Dispose results in Exception</title>
    <link>http://blog.arogldarthu.nl/archives/11-Proxys-Dispose-results-in-Exception.html</link>
            <category>WCF</category>
    
    <comments>http://blog.arogldarthu.nl/archives/11-Proxys-Dispose-results-in-Exception.html#comments</comments>
    <wfw:comment>http://blog.arogldarthu.nl/wfwcomment.php?cid=11</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://blog.arogldarthu.nl/rss.php?version=2.0&amp;type=comments&amp;cid=11</wfw:commentRss>
    

    <author>nospam@example.com (Twan Jacobs)</author>
    <content:encoded>
    A while ago I grabbed a WCF Membership example from &lt;a href=&quot;http://www.monstersgotmy.net/post/WCF-MembershipProvider-and-RoleProvider-Schweeeet.aspx&quot; title=&quot;Wcf Membership Provider&quot;&gt;here&lt;/a&gt;. Now that I&#039;ve been reading some more on WCF, I stumbled upon the following article: http://msdn.microsoft.com/en-us/library/aa355056.aspx&lt;br /&gt;
&lt;br /&gt;
How do you see this? Have you ever had these &#039;errors from IDisposable&#039; surface in production? Did you start rewriting every client call with try-catch-finally? Personally I&#039;m a bit appalled by the idea... Using the using statement keeps the code clean.&lt;br /&gt;
&lt;br /&gt;
So I started searching for a solution. This article (&lt;a href=&quot;http://www.iserviceoriented.com/blog/post/Indisposable+-+WCF+Gotcha+1.aspx&quot; title=&quot;Almost?&quot;&gt;WCF Gotcha #1&lt;/a&gt;) seems to provide a nice solution, but it&#039;s not exactly what I was hoping for.&lt;br /&gt;
&lt;br /&gt;
Ideas are very welcome! &lt;br /&gt;&lt;a href=&quot;http://blog.arogldarthu.nl/archives/11-Proxys-Dispose-results-in-Exception.html#extended&quot;&gt;Continue reading &quot;Proxy&#039;s Dispose results in Exception&quot;&lt;/a&gt;
    </content:encoded>

    <pubDate>Tue, 27 Jan 2009 09:58:10 +0000</pubDate>
    <guid isPermaLink="false">http://blog.arogldarthu.nl/archives/11-guid.html</guid>
    
</item>

</channel>
</rss>