Export (0) Print
Expand All

ContextUtil Class

Obtains information about the COM+ object context. This class cannot be inherited.

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

public sealed class ContextUtil
public final class ContextUtil
public final class ContextUtil

ContextUtil is the preferred class to use for obtaining COM+ context information. Because the members of this class are all static (shared in Visual Basic), it is not necessary to instantiate it before using them.

The following code example demonstrates how to use ContextUtil 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

System.Object
  System.EnterpriseServices.ContextUtil

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 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