ContextUtil ContextUtil ContextUtil ContextUtil Class

Definition

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

public ref class ContextUtil sealed
public sealed class ContextUtil
type ContextUtil = class
Public NotInheritable Class ContextUtil
Inheritance
ContextUtilContextUtilContextUtilContextUtil

Examples

The following code example demonstrates how to use ContextUtil to create a transactional ServicedComponent.


[assembly:System::Reflection::AssemblyKeyFile("Transaction.snk")];
[Transaction]
public ref class TransactionalComponent: public ServicedComponent
{
public:
   void TransactionalMethod( String^ data )
   {
      ContextUtil::DeactivateOnReturn = true;
      ContextUtil::MyTransactionVote = TransactionVote::Abort;
      
      // do work with data
      ContextUtil::MyTransactionVote = TransactionVote::Commit;
   }

};

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

    }

}
<Transaction()>  _
Public Class TransactionalComponent
    Inherits ServicedComponent
    
    
    Public Sub TransactionalMethod(ByVal data As String) 
        
        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
    
    End Sub 'TransactionalMethod 
End Class 'TransactionalComponent

Remarks

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.

Properties

ActivityId ActivityId ActivityId ActivityId

Gets a GUID representing the activity containing the component.

ApplicationId ApplicationId ApplicationId ApplicationId

Gets a GUID for the current application.

ApplicationInstanceId ApplicationInstanceId ApplicationInstanceId ApplicationInstanceId

Gets a GUID for the current application instance.

ContextId ContextId ContextId ContextId

Gets a GUID for the current context.

DeactivateOnReturn DeactivateOnReturn DeactivateOnReturn DeactivateOnReturn

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

IsInTransaction IsInTransaction IsInTransaction IsInTransaction

Gets a value that indicates whether the current context is transactional.

IsSecurityEnabled IsSecurityEnabled IsSecurityEnabled IsSecurityEnabled

Gets a value that indicates whether role-based security is active in the current context.

MyTransactionVote MyTransactionVote MyTransactionVote MyTransactionVote

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

PartitionId PartitionId PartitionId PartitionId

Gets a GUID for the current partition.

SystemTransaction SystemTransaction SystemTransaction SystemTransaction

Gets the current transaction context.

Transaction Transaction Transaction Transaction

Gets an object describing the current COM+ DTC transaction.

TransactionId TransactionId TransactionId TransactionId

Gets the GUID of the current COM+ DTC transaction.

Methods

DisableCommit() DisableCommit() DisableCommit() DisableCommit()

Sets both the consistent bit and the done bit to false in the COM+ context.

EnableCommit() EnableCommit() EnableCommit() EnableCommit()

Sets the consistent bit to true and the done bit to false in the COM+ context.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetNamedProperty(String) GetNamedProperty(String) GetNamedProperty(String) GetNamedProperty(String)

Returns a named property from the COM+ context.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
IsCallerInRole(String) IsCallerInRole(String) IsCallerInRole(String) IsCallerInRole(String)

Determines whether the caller is in the specified role.

IsDefaultContext() IsDefaultContext() IsDefaultContext() 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.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
SetAbort() SetAbort() SetAbort() SetAbort()

Sets the consistent bit to false and the done bit to true in the COM+ context.

SetComplete() SetComplete() SetComplete() SetComplete()

Sets the consistent bit and the done bit to true in the COM+ context.

SetNamedProperty(String, Object) SetNamedProperty(String, Object) SetNamedProperty(String, Object) SetNamedProperty(String, Object)

Sets the named property for the COM+ context.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to