Export (0) Print
Expand All

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 */
public static TransactionVote get_MyTransactionVote ()

/** @property */
public static void set_MyTransactionVote (TransactionVote value)

public static function get MyTransactionVote () : TransactionVote

public static function set MyTransactionVote (value : TransactionVote)

Property Value

One of the TransactionVote values, either Commit or Abort.

Exception typeCondition

COMException

There is no COM+ context available.

PlatformNotSupportedException

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.

[Transaction]
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;

    }

}

/** @attribute Transaction()
 */
public class TransactionalComponent extends ServicedComponent
{
    public void TransactionalMethod(String data)
    {
        ContextUtil.set_DeactivateOnReturn(true);
        ContextUtil.set_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.set_MyTransactionVote(TransactionVote.Commit);
    } //TransactionalMethod 
} //TransactionalComponent

  • Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft