Export (0) Print
Expand All

ContextUtil.DeactivateOnReturn Property

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

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

public static bool DeactivateOnReturn { get; set; }
/** @property */
public static boolean get_DeactivateOnReturn ()

/** @property */
public static void set_DeactivateOnReturn (boolean value)

public static function get DeactivateOnReturn () : boolean

public static function set DeactivateOnReturn (value : boolean)

Property Value

true if the object is to be deactivated when the method returns; otherwise, false. The default is false.

Exception typeCondition

COMException

There is no COM+ context available.

PlatformNotSupportedException

The platform is not Windows 2000 or later.

The COM+ done bit determines how long the object remains active after finishing its work and can affect the duration of a transaction. When a method call returns, COM+ inspects the done bit. If the done bit is true, COM+ deactivates the object. If the done bit is false, the object is not deactivated.

The following code example demonstrates the use of the DeactivateOnReturn property to ensure that a ServicedComponent is deactivated after a method call.

[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