ContextUtil.MyTransactionVote Property


Gets or sets the consistent bit in the COM+ context.

Namespace:   System.EnterpriseServices
Assembly:  System.EnterpriseServices (in System.EnterpriseServices.dll)

public static TransactionVote MyTransactionVote { get; set; }

Property Value

Type: System.EnterpriseServices.TransactionVote

One of the TransactionVote values, either Commit or Abort.

Exception Condition

There is no COM+ context available.


The platform is not Windows 2000 or later.

When MyTransactionVote is set to Commit, the COM+ consistent bit is set to true and the COM+ context votes to commit the transaction. If MyTransactionVote is set to Abort, the consistent bit is set to false and the COM+ context votes to abort the transaction. The default value of the consistent bit is true.

The consistent bit casts a vote to commit or abort the transaction in which it executes, and the done bit finalizes the vote. COM+ inspects the consistent bit when the done bit is set to true on a method call return or when the object deactivates. Although an object's consistent bit can change repeatedly within each method call, only the last change counts.

The following code example demonstrates how to use MyTransactionVote property to create a transactional ServicedComponent.

public class TransactionalComponent : ServicedComponent

    public void TransactionalMethod (string data)

      ContextUtil.DeactivateOnReturn = true;
      ContextUtil.MyTransactionVote = TransactionVote.Abort;

      // Do work with data. Return if any errors occur.

      // Vote to commit. If any errors occur, this code will not execute.
      ContextUtil.MyTransactionVote = TransactionVote.Commit;



.NET Framework
Available since 1.1
Return to top