Breyta

Deila með


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
ContextUtil

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

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

Gets a GUID representing the activity containing the component.

ApplicationId

Gets a GUID for the current application.

ApplicationInstanceId

Gets a GUID for the current application instance.

ContextId

Gets a GUID for the current context.

DeactivateOnReturn

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

IsInTransaction

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

IsSecurityEnabled

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

MyTransactionVote

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

PartitionId

Gets a GUID for the current partition.

SystemTransaction

Gets the current transaction context.

Transaction

Gets an object describing the current COM+ DTC transaction.

TransactionId

Gets the GUID of the current COM+ DTC transaction.

Methods

DisableCommit()

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

EnableCommit()

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

Equals(Object)

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

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetNamedProperty(String)

Returns a named property from the COM+ context.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
IsCallerInRole(String)

Determines whether the caller is in the specified role.

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

Creates a shallow copy of the current Object.

(Inherited from Object)
SetAbort()

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

SetComplete()

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

SetNamedProperty(String, Object)

Sets the named property for the COM+ context.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to