TransactionAttribute Class
.NET Framework 2.0
Specifies the type of transaction that is available to the attributed object. Permissible values are members of the TransactionOption enumeration.
Namespace: System.EnterpriseServices
Assembly: System.EnterpriseServices (in system.enterpriseservices.dll)
Assembly: System.EnterpriseServices (in system.enterpriseservices.dll)
[ComVisibleAttribute(false)] [AttributeUsageAttribute(AttributeTargets.Class, Inherited=true)] public sealed class TransactionAttribute : Attribute
/** @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 : 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; } }
/** @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.