title: Return WCF Custom Fault Exception
body: <p>I am having bit of trouble returning custom fault exception from wcf service.  The client application talking to wcf service gets – contract mismatch error.
  Here is my fault contract defined in the service:</p>
  
  <pre><code>public partial class Fault
  {
      string codeField;
      string messageField;
      string detailsField;
  }
  </code></pre>
  
  <p>On error in the service I am creating custom fault exception as following:</p>
  
  <pre><code>public void ProvideFault(Exception exception, MessageVersion version, ref Message       refMessage)
  {
        mynamespace.Fault customFault = new mynamespace.Fault()
        {
             code = "Service Error",
             message = "Error Message",
             details = "Error Message"
        };
  
        FaultException&lt;mynamespace.Fault&gt; faultexception = new   FaultException&lt;mynamespace.Fault&gt;( customFault );
  
        MessageFault messageFault = faultexception.CreateMessageFault();
  
        refMessage = Message.CreateMessage( version, messageFault, faultNamespace );
  }
  </code></pre>
  
  <p>This code causes contract mismatch error in client. Can anyone please help me finding what is wrong?</p>