<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Simplifying WCF: Using Exceptions as Faults</title>
	<link>http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/</link>
	<description>Interfaces are like alcohol - they are a lot of fun when used in moderation.</description>
	<pubDate>Sat, 04 Feb 2012 05:37:08 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
		<item>
		<title>By: Tony Carl</title>
		<link>http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/#comment-3437</link>
		<dc:creator>Tony Carl</dc:creator>
		<pubDate>Mon, 25 Jul 2011 22:09:56 +0000</pubDate>
		<guid>http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/#comment-3437</guid>
		<description>Not sure if anyone has a better solution for Fault Exceptions (see Bunty Singh post above). What I did was change replace the FileNotFoundException catch to just a generic Exception catch when it tries to read from the serializer in ExceptionMarshallingMessageInspector.cs. The code looks like this now:   

                NetDataContractSerializer serializer = new NetDataContractSerializer();
                try
                {
                    return serializer.ReadObject(reader);
                }
                catch (SerializationException)
                {
                    // Serializer was unable to find assembly where exception is defined 
                    return null;
                }

Seems a little hackish to ignore all SerializationExceptions. With this change, I can successfully catch FaultException.</description>
		<content:encoded><![CDATA[<p>Not sure if anyone has a better solution for Fault Exceptions (see Bunty Singh post above). What I did was change replace the FileNotFoundException catch to just a generic Exception catch when it tries to read from the serializer in ExceptionMarshallingMessageInspector.cs. The code looks like this now:   </p>
<p>                NetDataContractSerializer serializer = new NetDataContractSerializer();<br />
                try<br />
                {<br />
                    return serializer.ReadObject(reader);<br />
                }<br />
                catch (SerializationException)<br />
                {<br />
                    // Serializer was unable to find assembly where exception is defined<br />
                    return null;<br />
                }</p>
<p>Seems a little hackish to ignore all SerializationExceptions. With this change, I can successfully catch FaultException.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hashname</title>
		<link>http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/#comment-3428</link>
		<dc:creator>Hashname</dc:creator>
		<pubDate>Wed, 15 Jun 2011 11:49:04 +0000</pubDate>
		<guid>http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/#comment-3428</guid>
		<description>Awesome!!! 
Still I'm kind of freaked out about the extent of coding required to get basic stuff like exception handling to work seamlessly in WCF.</description>
		<content:encoded><![CDATA[<p>Awesome!!!<br />
Still I&#8217;m kind of freaked out about the extent of coding required to get basic stuff like exception handling to work seamlessly in WCF.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Getting something better than &#8220;Server not found.&#8221; from WCF in Silverlight &#171; Matt Duffield</title>
		<link>http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/#comment-3390</link>
		<dc:creator>Getting something better than &#8220;Server not found.&#8221; from WCF in Silverlight &#171; Matt Duffield</dc:creator>
		<pubDate>Wed, 06 Apr 2011 14:18:08 +0000</pubDate>
		<guid>http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/#comment-3390</guid>
		<description>[...] I find very instrumental in dealing with exceptions in WCF. Oleg Sych wrote an excellent article, Simplifying WCF: Using Exceptions as Faults, back in 2008 that I believe is still very pertinent for us today. His solutions is very similar to [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] I find very instrumental in dealing with exceptions in WCF. Oleg Sych wrote an excellent article, Simplifying WCF: Using Exceptions as Faults, back in 2008 that I believe is still very pertinent for us today. His solutions is very similar to [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harvo Jones</title>
		<link>http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/#comment-3195</link>
		<dc:creator>Harvo Jones</dc:creator>
		<pubDate>Tue, 27 Jul 2010 19:38:01 +0000</pubDate>
		<guid>http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/#comment-3195</guid>
		<description>Oleg, very good stuff.  Thanks for helping us navigate the intricacies of WCF configuration.</description>
		<content:encoded><![CDATA[<p>Oleg, very good stuff.  Thanks for helping us navigate the intricacies of WCF configuration.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Unwrap WCF FaultException &#171; maonet technotes</title>
		<link>http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/#comment-2898</link>
		<dc:creator>Unwrap WCF FaultException &#171; maonet technotes</dc:creator>
		<pubDate>Wed, 10 Feb 2010 17:04:56 +0000</pubDate>
		<guid>http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/#comment-2898</guid>
		<description>[...] other faultexception, so I don&#8217;t need investigating ExceptionMarshallingBehavior described here and [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] other faultexception, so I don&#8217;t need investigating ExceptionMarshallingBehavior described here and [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: A debug only WCF Exception problem &#171; maonet technotes</title>
		<link>http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/#comment-2690</link>
		<dc:creator>A debug only WCF Exception problem &#171; maonet technotes</dc:creator>
		<pubDate>Thu, 31 Dec 2009 16:13:26 +0000</pubDate>
		<guid>http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/#comment-2690</guid>
		<description>[...] http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/ [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] <a href="http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/" rel="nofollow">http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/</a> [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wout</title>
		<link>http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/#comment-2545</link>
		<dc:creator>Wout</dc:creator>
		<pubDate>Wed, 16 Dec 2009 21:09:08 +0000</pubDate>
		<guid>http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/#comment-2545</guid>
		<description>Hi, thanks for the insights! I couldn't get the IErrorHandler to work still, but I did find a sneaky workaround. I've just written a post about the details (seems bl##dy .NET BCL bug): http://www.woutware.com/blog/post/Implementing-IErrorHandler-and-working-around-SerializationException.aspx

- Wout</description>
		<content:encoded><![CDATA[<p>Hi, thanks for the insights! I couldn&#8217;t get the IErrorHandler to work still, but I did find a sneaky workaround. I&#8217;ve just written a post about the details (seems bl##dy .NET BCL bug): <a href="http://www.woutware.com/blog/post/Implementing-IErrorHandler-and-working-around-SerializationException.aspx" rel="nofollow">http://www.woutware.com/blog/post/Implementing-IErrorHandler-and-working-around-SerializationException.aspx</a></p>
<p>- Wout</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike V</title>
		<link>http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/#comment-2433</link>
		<dc:creator>Mike V</dc:creator>
		<pubDate>Tue, 10 Nov 2009 21:41:29 +0000</pubDate>
		<guid>http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/#comment-2433</guid>
		<description>FYI, your zip file appears to be missing the file "Examples.cs".</description>
		<content:encoded><![CDATA[<p>FYI, your zip file appears to be missing the file &#8220;Examples.cs&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bunty Singh</title>
		<link>http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/#comment-1216</link>
		<dc:creator>Bunty Singh</dc:creator>
		<pubDate>Wed, 01 Apr 2009 09:37:17 +0000</pubDate>
		<guid>http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/#comment-1216</guid>
		<description>Firstly thanks for your wonderful explanation.

One wierd thing that I have noticed was, though exceptions cannot be serialized using DataContractSerializer hance the NetDataContractSerializer. However is the client throws FaulException instead of the exception i.e. instead of client throwing say ArgumentNullException if it throws FaultException, the error handler will be bypassed and the exception get serialized using the normal DataContractSerializer without any serialization exception. And at the client end you would IClientMessageInspector would throw serialization exception.</description>
		<content:encoded><![CDATA[<p>Firstly thanks for your wonderful explanation.</p>
<p>One wierd thing that I have noticed was, though exceptions cannot be serialized using DataContractSerializer hance the NetDataContractSerializer. However is the client throws FaulException instead of the exception i.e. instead of client throwing say ArgumentNullException if it throws FaultException, the error handler will be bypassed and the exception get serialized using the normal DataContractSerializer without any serialization exception. And at the client end you would IClientMessageInspector would throw serialization exception.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael Carr</title>
		<link>http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/#comment-1198</link>
		<dc:creator>Michael Carr</dc:creator>
		<pubDate>Fri, 13 Mar 2009 18:10:30 +0000</pubDate>
		<guid>http://www.olegsych.com/2008/07/simplifying-wcf-using-exceptions-as-faults/#comment-1198</guid>
		<description>I believe I've isolated the problem with BasicHttpBinding. The two bindings (NetTcpBinding vs BasicHttpBinding) seem to use different Fault objects when serializing faults. The NetTcpBinding uses a Fault that serializes out with a "Details" tag, while the BasicHttpBinding uses a Fault that serializes out with a "details" tag. This causes the ExceptionMarshallingMessageInspector to break when trying to locate the Details element. I modified the code as follows to fix this problem:

ExceptionMarshallingMessageInspector.cs:

40: const string detailElementName = "detail";

47: if (reader.NodeType == XmlNodeType.Element &#38;&#38; reader.LocalName.ToLower() == detailElementName)

54: if (reader.NodeType != XmlNodeType.Element &#124;&#124; reader.LocalName.ToLower() != detailElementName)</description>
		<content:encoded><![CDATA[<p>I believe I&#8217;ve isolated the problem with BasicHttpBinding. The two bindings (NetTcpBinding vs BasicHttpBinding) seem to use different Fault objects when serializing faults. The NetTcpBinding uses a Fault that serializes out with a &#8220;Details&#8221; tag, while the BasicHttpBinding uses a Fault that serializes out with a &#8220;details&#8221; tag. This causes the ExceptionMarshallingMessageInspector to break when trying to locate the Details element. I modified the code as follows to fix this problem:</p>
<p>ExceptionMarshallingMessageInspector.cs:</p>
<p>40: const string detailElementName = &#8220;detail&#8221;;</p>
<p>47: if (reader.NodeType == XmlNodeType.Element &amp;&amp; reader.LocalName.ToLower() == detailElementName)</p>
<p>54: if (reader.NodeType != XmlNodeType.Element || reader.LocalName.ToLower() != detailElementName)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

