TransactionAttribute Class
Assembly: System.EnterpriseServices (in system.enterpriseservices.dll)
'Declaration <ComVisibleAttribute(False)> _ <AttributeUsageAttribute(AttributeTargets.Class, Inherited:=True)> _ Public NotInheritable Class TransactionAttribute Inherits Attribute 'Usage Dim instance As TransactionAttribute
/** @attribute ComVisibleAttribute(false) */ /** @attribute AttributeUsageAttribute(AttributeTargets.Class, Inherited=true) */ public final class TransactionAttribute extends Attribute
ComVisibleAttribute(false) AttributeUsageAttribute(AttributeTargets.Class, Inherited=true) public final class TransactionAttribute extends Attribute
If a transaction type is specified with this attribute, it must not be changed in the COM+ catalog. If the transaction type is changed in the COM+ catalog, the same transaction type must be specified on the component with this attribute.
For more information about using attributes, see Extending Metadata Using Attributes.
The following code example demonstrates the use of the TransactionAttribute to mark a ServicedComponent as transactional.
<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
/** @attribute Transaction()
*/
public class TransactionalComponent extends ServicedComponent
{
public void TransactionalMethod(String data)
{
ContextUtil.set_DeactivateOnReturn(true);
ContextUtil.set_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.set_MyTransactionVote(TransactionVote.Commit);
} //TransactionalMethod
} //TransactionalComponent
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.