title: client will not catch generic FaultException< T >, only FaultException
body: <p>I've read all there is to read on this, but maybe I'm missing something (well, definitely I'm missing something otherwise it would be working already)</p>
  
  <p>I'm throwing some exception error inside my server business layer:</p>
  
  <pre><code>public class RfcException :  Exception
  {
     public RfcException(string _m, Exception _inner) : base(_m, _inner)
     { }
  
     public Dictionary&lt;string, string&gt; ExtendedProperties
     {
        get { return extendedProperties; }
        protected set { extendedProperties = value; }
     }
  
     private Dictionary&lt;string, string&gt; extendedProperties = new Dictionary&lt;string, string&gt;();
  }
  </code></pre>
  
  <p>which I leave unhandled in the service, but I have an <code>IErrorHandler</code> to catch and create a <code>FaultMessage</code>:</p>
  
  <pre><code>public class FaultErrorHandler : BehaviorExtensionElement, IErrorHandler, IServiceBehavior
  {
     public bool HandleError(Exception error)
     {
        if (!Logger.IsLoggingEnabled()) return true;
        var logEntry = new LogEntry
          {
             EventId = 100,
             Severity = TraceEventType.Error,
             Priority = 1,
             Title = "WCF Failure",
             Message = string.Format("Error occurred: {0}", error)
          };
        logEntry.Categories.Add("MiddleTier");
  
        Logger.Write(logEntry);
        return true;
     }
  
     public void ProvideFault(Exception error, System.ServiceModel.Channels.MessageVersion version, ref System.ServiceModel.Channels.Message fault)
     {
        if (error is RfcException)
        {
           RfcException rfcException = error as RfcException;
           var serviceFault = new RfcServiceFault(rfcException);
           var faultException = new FaultException&lt;RfcServiceFault&gt;(serviceFault, new FaultReason(string.Format("System error occurred, exception: {0}", error)));
           var faultMessage = faultException.CreateMessageFault();
           fault = Message.CreateMessage(version, faultMessage, Schema.WebServiceStandard);
        }
        else
        {
           var faultException = new FaultException&lt;Exception&gt;(error, new FaultReason(string.Format("System error occurred, exception: {0}", error)));
           var faultMessage = faultException.CreateMessageFault();
           fault = Message.CreateMessage(version, faultMessage, Schema.WebServiceStandard);
        }
     }
  
     public void AddBindingParameters(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase, System.Collections.ObjectModel.Collection&lt;ServiceEndpoint&gt; endpoints, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
     { }
  
     public void ApplyDispatchBehavior(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase)
     {
        foreach (ChannelDispatcher chanDisp in serviceHostBase.ChannelDispatchers)
        {
           chanDisp.ErrorHandlers.Add(this);
        };
     }
  
     public void Validate(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase)
     { }
  
     public override Type BehaviorType
     {
        get { return typeof(FaultErrorHandler); }
     }
  
     protected override object CreateBehavior()
     {
        return new FaultErrorHandler();
     }
  }
  </code></pre>
  
  <p>No need to ask; I already confirmed with the debugger its entering in the part <code>if (error is RfcException)</code> part, I've stepped through that code and it reach til the end without any trouble.
  That errorHandler wraps a <code>FaultException&lt;RfcServiceFault&gt;</code> message, the <code>RfcServiceFault</code> message is this</p>
  
  <pre><code>[DataContract(Name = "RfcServiceFault", Namespace = "Service.DataTransfer.Rfc")]
  public class RfcServiceFault 
  {
     public RfcServiceFault(RfcException rfcException) : this( (Exception)rfcException )
     {
        ExtendedProperties = new Dictionary&lt;string, string&gt;(rfcException.ExtendedProperties);
     }
  
     public RfcServiceFault()
     { }
  
     public RfcServiceFault(Exception regularException)
     {
        FaultMessage = regularException.Message;
        StackTrace = regularException.StackTrace;
     }
  
     public Dictionary&lt;string, string&gt; ExtendedProperties
     {
        get { return extendedProperties; }
        protected set { extendedProperties = value; }
     }
  
     [DataMember]
     private Dictionary&lt;string, string&gt; extendedProperties = new Dictionary&lt;string, string&gt;();
  
     [DataMember]
     public string FaultMessage { get; set; }
  
     [DataMember]
     public string StackTrace { get; set; }
  }
  </code></pre>
  
  <p>The service has all the annotations that should have a wcf service with a faultContract:</p>
  
  <pre><code>[ServiceContract(Name = "MyService", Namespace = Schema.WebServiceStandard, SessionMode = SessionMode.Allowed)]
  public interface IMyService 
  {
      [OperationContract(Name = "GetStuff")]
      [FaultContract(typeof(RfcServiceFault) , Name="RfcServiceFault", Namespace="Service.DataTransfer.Rfc")]
      LookupResult GetStuff();
  }
  </code></pre>
  
  <p><strong>Now:</strong> testing at the client, a simple test like this:</p>
  
  <pre><code>try
  {
     var result = myService.GetStuff();
     Assert.IsTrue(!string.IsNullOrEmpty(result));
  }
  catch (FaultException&lt;RfcServiceFault&gt; rfcEx)
  {
     // OMG FOR THE LIFE OF THE PUPPIES ENTER HERE
  }
  catch (FaultException rr)
  {
     // it always falls in here
  }
  catch (Exception ex)
  { }
  </code></pre>
  
  <p>I've read, many, many posts about this similar issue:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/48340/cannot-handle-faultexception">Cannot handle FaultException</a></li>
  <li><a href="https://stackoverflow.com/questions/648084/throwing-generic-faultexception">Throwing generic FaultException</a></li>
  <li><a href="https://stackoverflow.com/questions/4140030/c-wcf-catch-fault-exceptions-of-base-type">c# WCF catch Fault Exceptions of Base type</a></li>
  <li><a href="https://stackoverflow.com/questions/2455077/wcf-wsdl-first-approach-problems-with-generating-fault-types">WCF: WSDL-first approach: Problems with generating fault types</a></li>
  </ul>
  
  <p>but nothing so far seems to help, I've tried setting up WCF tracing in the web.config:</p>
  
  <pre><code>&lt;system.diagnostics&gt;
      &lt;sources&gt;
        &lt;source name="System.ServiceModel"
                switchValue="Information, ActivityTracing"&gt;
          &lt;listeners&gt;
            &lt;add name="log"
                 type="System.Diagnostics.XmlWriterTraceListener"
                 initializeData="c:\Traces.svclog" /&gt;
          &lt;/listeners&gt;
        &lt;/source&gt;
      &lt;/sources&gt;
    &lt;/system.diagnostics&gt;
  </code></pre>
  
  <p>and I get a svclog file in there, I open with WCF Trace viewer, but I only see a bunch of messages, the yellow one show the Exception, but it only confirms what the client is already seeing, a <code>System.ServiceModel.FaultException</code> being received, rather than the generic one</p>
  
  <p>Any ideas how to figure this out?</p>
  
  <p><strong>EDIT</strong> forgot to mention, i enabled my error handler in config like this:</p>
  
  <pre><code>&lt;behaviorExtensions&gt;
     .....
      &lt;add name="faultErrorHandlerBehavior" 
           type="Service.FaultErrorHandler,Service, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /&gt;
      .....
  &lt;/behaviorExtensions&gt;
  &lt;serviceBehaviors&gt;
     &lt;behavior name="ServiceBehavior"&gt;
         &lt;serviceThrottling maxConcurrentCalls="200" maxConcurrentSessions="200"
                            maxConcurrentInstances="200" /&gt;
         &lt;serviceMetadata httpGetEnabled="true" /&gt;
         &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
         &lt;faultErrorHandlerBehavior /&gt;
      &lt;/behavior&gt;
  &lt;/serviceBehaviors&gt;
  </code></pre>