TransactionAttribute Class
Specifies the type of transaction that is available to the attributed object. Permissible values are members of the TransactionOption enumeration.
Assembly: System.EnterpriseServices (in System.EnterpriseServices.dll)
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
[Transaction]
public __gc class TransactionalComponent : public ServicedComponent {
public:
void TransactionalMethod (String* data) {
ContextUtil::DeactivateOnReturn = true;
ContextUtil::MyTransactionVote = TransactionVote::Abort;
// do work with data
ContextUtil::MyTransactionVote = TransactionVote::Commit;
}
};
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.