title: How to handle a FaultException in WCF without aborting the whole transaction?
body: <p>I have a WCF service being called as part of a transaction.</p>
  
  <p>If the service is called twice (often happening during debugging) <strong>I want a FaultException to be thrown by the service but the overall transaction must succeed</strong>.</p>
  
  <pre><code> throw new FaultException("Duplicate action not allowed for " + 
                            msgIn.ActionType, new FaultCode("DUPE_ACTION"));
  </code></pre>
  
  <p>Since I'm throwing a FaultException the transaction will vote to abort right?</p>
  
  <p>I'm considering doing this (setting the transaction complete - and then throwing the fault) - but i don't even know if that will work. It also has <a href="http://codeidol.com/csharp/wcf/Transactions/Transactional-Service-Programming/" rel="nofollow noreferrer">some complications</a> that I don't want to have to worry about.</p>
  
  <pre><code>[OperationBehavior(TransactionScopeRequired = true,
                     TransactionAutoComplete = false)]
  public void MyMethod(...)
  {
     try
     {
        OperationContext.Current.SetTransactionComplete( );
        throw new FaultException("Duplicate action not allowed for " + 
                            msgIn.ActionType, new FaultCode("DUPE_ACTION"));
     }
     catch
     {
        /* Do some error handling then */
        throw;
     }
  }
  </code></pre>
  
  <p>An obvious solution is to return a message with a <code>Success</code> parameter - which is what I originally did - but that's bad design because ultimately it is a Fault and deserves to have an exception. </p>
  
  <p>Or is the solution as simple as having my client catch the Fault and continue with the transaction. I'm concerned that voting has already taken place through.</p>
  
  <p>What's the best way to allow a WCF service to throw a fault but still allow the transaction to succeed? </p>