title: Can I prevent WCF from rolling back the transaction when a fault is thrown?
body: <p>Consider the following WCF service which participates in a distributed transaction.  The normal behavior of WCF is to roll back the transaction if any fault occurs.  Is there any way to override that behavior?</p>
  
  <p>Service contract:</p>
  
  <pre><code>[ServiceContract]
  public interface ITestService {
      [OperationContract]
      [FaultContract(typeof(TestServiceFault))]
      void ThrowError();
      [OperationContract]
      void DoSomething();
      [OperationContract]
      void DoSomethingElse();
  }
  
  [DataContract]
  public class TestServiceFault{}
  </code></pre>
  
  <p>Service implementation:</p>
  
  <pre><code>class TestService : ITestService {
      [OperationBehavior(TransactionScopeRequired = true)]
      [TransactionFlow(TransactionFlowOption.Mandatory)]
      public void ThrowError() {
          throw new FaultException&lt;TestServiceFault&gt;(new TestServiceFault());
      }
      [OperationBehavior(TransactionScopeRequired = true)]
      [TransactionFlow(TransactionFlowOption.Mandatory)]
      public void DoSomething() {
          //
          // ...
          //
      }
      [OperationBehavior(TransactionScopeRequired = true)]
      [TransactionFlow(TransactionFlowOption.Mandatory)]
      public void DoSomethingElse() {
          //
          // ...
          //
      }
  }
  </code></pre>
  
  <p>Client implementation snippet:</p>
  
  <pre><code>using(new TransactionScope()) {
      testServiceClient.DoSomething();
  
      try {
          testServiceClient.ThrowError();
      } catch(FaultException&lt;TestServiceFault&gt;) {}
  
      testServiceClient.DoSomethingElse();
  }
  </code></pre>
  
  <p>When the FaultException is thrown from <strong>ThrowError()</strong>, WCF rolls back the distributed transaction which includes the work done by <strong>DoSomething()</strong>.  Then, the client call to <strong>DoSomethingElse()</strong> fails with the message <em>The flowed transaction could not be unmarshaled. The following exception occurred: The transaction has already been implicitly or explicitly committed or aborted.</em></p>
  
  <p>In my particular scenario this behavior is undesirable.  I'd like to catch the exception on the client side and continue about my business.  If any exceptions occur that I don't catch, the client will be roll back the transaction.</p>
  
  <p>Note: This question is a duplicate of <a href="https://stackoverflow.com/questions/1993592">How to handle a FaultException in WCF without aborting the whole transaction?</a>, but the accepted answer there isn't satisfactory to me - it's important that all of the operations happen within the same transaction scope.</p>