Export (0) Print
Expand All

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.

  NameDescription
Public propertyStatic memberActivityIdGets a GUID representing the activity containing the component.
Public propertyStatic memberApplicationIdGets a GUID for the current application.
Public propertyStatic memberApplicationInstanceIdGets a GUID for the current application instance.
Public propertyStatic memberContextIdGets a GUID for the current context.
Public propertyStatic memberDeactivateOnReturnGets or sets the done bit in the COM+ context.
Public propertyStatic memberIsInTransactionGets a value that indicates whether the current context is transactional.
Public propertyStatic memberIsSecurityEnabledGets a value that indicates whether role-based security is active in the current context.
Public propertyStatic memberMyTransactionVoteGets or sets the consistent bit in the COM+ context.
Public propertyStatic memberPartitionIdGets a GUID for the current partition.
Public propertyStatic memberSystemTransactionGets the current transaction context.
Public propertyStatic memberTransactionGets an object describing the current COM+ DTC transaction.
Public propertyStatic memberTransactionIdGets the GUID of the current COM+ DTC transaction.
Top

  NameDescription
Public methodStatic memberDisableCommitSets both the consistent bit and the done bit to false in the COM+ context.
Public methodStatic memberEnableCommitSets the consistent bit to true and the done bit to false in the COM+ context.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodStatic memberGetNamedPropertyReturns a named property from the COM+ context.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodStatic memberIsCallerInRoleDetermines whether the caller is in the specified role.
Public methodStatic memberIsDefaultContextDetermines 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.
Public methodStatic memberSetAbortSets the consistent bit to false and the done bit to true in the COM+ context.
Public methodStatic memberSetCompleteSets the consistent bit and the done bit to true in the COM+ context.
Public methodStatic memberSetNamedPropertySets the named property for the COM+ context.
Public methodToStringReturns 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.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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.
Show:
© 2014 Microsoft