TransactionFlowAttribute Class

Specifies the willingness of a service operation to accept incoming transactions from a client.

Namespace: System.ServiceModel
Assembly: System.ServiceModel (in system.servicemodel.dll)

public sealed class TransactionFlowAttribute : Attribute, IOperationBehavior
/** @attribute AttributeUsageAttribute(AttributeTargets.Method) */ 
public final class TransactionFlowAttribute extends Attribute implements IOperationBehavior
public final class TransactionFlowAttribute extends Attribute implements IOperationBehavior
Not applicable.

The TransactionFlowAttribute is an attribute used declaratively to associate a specific transaction flow policy with a service operation. The TransactionFlowOption property of this attribute specifies whether the respective operation may accept a transaction flowed from the client, or if the operation requires the client to always flow a transaction. The TransactionFlowAttribute can also be used as an operation behavior to programmatically associate a transaction flow policy with a specific operation. In this case, it should be added to the Behaviors collection on the operation’s description.


The OperationContract for each method that uses the TransactionFlowAttribute must provide a fully qualified Action string. A value of "*" is not supported.

The following code example demonstrates the use of this enumeration together with the TransactionFlowOption class at the operation level.

using System;
using System.ServiceModel;
using System.Transactions;

namespace Microsoft.WCF.Documentation
  public interface IBehaviorService
    string TxWork(string message);

  // Note: To use the TransactionIsolationLevel property, you 
  // must add a reference to the System.Transactions.dll assembly.
  /* The following service implementation:
   *   -- Processes messages on one thread at a time
   *   -- Creates one service object per session
   *   -- Releases the service object when the transaction commits
  public class BehaviorService : IBehaviorService, IDisposable
    Guid myID;

    public BehaviorService()
      myID = Guid.NewGuid();
        "Object "
        + myID.ToString()
        + " created.");

    / * The following operation-level behaviors are specified:
    / * Always executes under a transaction scope.
    / * The transaction scope is completed when the operation
    / * terminates without an unhandled exception.
      TransactionAutoComplete = true,
      TransactionScopeRequired = true
    public string TxWork(string message)
      // Do some transactable work.
      Console.WriteLine("TxWork called with: " + message);
      // Display transaction information.

      TransactionInformation info = Transaction.Current.TransactionInformation;
      Console.WriteLine("The distributed tx ID: {0}.", info.DistributedIdentifier);
      Console.WriteLine("The tx status: {0}.", info.Status);
      return String.Format("Hello. This was object {0}.",myID.ToString()) ;

    public void Dispose()
        "Service "
        + myID.ToString()
        + " is being recycled."


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions