This topic has not yet been rated - Rate this topic

ContextUtil Class

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

System.Object
  System.EnterpriseServices.ContextUtil

Namespace:  System.EnterpriseServices
Assembly:  System.EnterpriseServices (in System.EnterpriseServices.dll)
public sealed class ContextUtil

The ContextUtil type exposes the following members.

  Name Description
Public property Static member ActivityId Gets a GUID representing the activity containing the component.
Public property Static member ApplicationId Gets a GUID for the current application.
Public property Static member ApplicationInstanceId Gets a GUID for the current application instance.
Public property Static member ContextId Gets a GUID for the current context.
Public property Static member DeactivateOnReturn Gets or sets the done bit in the COM+ context.
Public property Static member IsInTransaction Gets a value that indicates whether the current context is transactional.
Public property Static member IsSecurityEnabled Gets a value that indicates whether role-based security is active in the current context.
Public property Static member MyTransactionVote Gets or sets the consistent bit in the COM+ context.
Public property Static member PartitionId Gets a GUID for the current partition.
Public property Static member SystemTransaction Gets the current transaction context.
Public property Static member Transaction Gets an object describing the current COM+ DTC transaction.
Public property Static member TransactionId Gets the GUID of the current COM+ DTC transaction.
Top
  Name Description
Public method Static member DisableCommit Sets both the consistent bit and the done bit to false in the COM+ context.
Public method Static member EnableCommit Sets the consistent bit to true and the done bit to false in the COM+ context.
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method Static member GetNamedProperty Returns a named property from the COM+ context.
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method Static member IsCallerInRole Determines whether the caller is in the specified role.
Public method Static member IsDefaultContext Determines whether the serviced component is activated in the default context. Serviced components that do not have COM+ catalog information are activated in the default context.
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Static member SetAbort Sets the consistent bit to false and the done bit to true in the COM+ context.
Public method Static member SetComplete Sets the consistent bit and the done bit to true in the COM+ context.
Public method Static member SetNamedProperty Sets the named property for the COM+ context.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Top

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;

    }

}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ