ContextUtil Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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 |
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 |
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 |
EnableCommit() |
Sets the |
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 |
SetComplete() |
Sets the |
SetNamedProperty(String, Object) |
Sets the named property for the COM+ context. |
ToString() |
Returns a string that represents the current object. (Inherited from Object) |