System.Transactions Namespace

 

The System.Transactions namespace contains classes that allow you to write your own transactional application and resource manager. Specifically, you can create and participate in a transaction (local or distributed) with one or multiple participants.

ClassDescription
System_CAPS_pubclassCommittableTransaction

Describes a committable transaction.

System_CAPS_pubclassDependentTransaction

Describes a clone of a transaction providing guarantee that the transaction cannot be committed until the application comes to rest regarding work on the transaction. This class cannot be inherited.

System_CAPS_pubclassDistributedTransactionPermission

The permission that is demanded by System.Transactions when management of a transaction is escalated to MSDTC. This class cannot be inherited.

System_CAPS_pubclassDistributedTransactionPermissionAttribute

Allows security actions for DistributedTransactionPermission to be applied to code using declarative security. This class cannot be inherited.

System_CAPS_pubclassEnlistment

Facilitates communication between an enlisted transaction participant and the transaction manager during the final phase of the transaction.

System_CAPS_pubclassPreparingEnlistment

Facilitates communication between an enlisted transaction participant and the transaction manager during the Prepare phase of the transaction.

System_CAPS_pubclassSinglePhaseEnlistment

Provides a set of callbacks that facilitate communication between a participant enlisted for Single Phase Commit and the transaction manager when the SinglePhaseCommit notification is received.

System_CAPS_pubclassSubordinateTransaction

Represents a non-rooted transaction that can be delegated. This class cannot be inherited.

System_CAPS_pubclassTransaction

Represents a transaction.

System_CAPS_pubclassTransactionAbortedException

The exception that is thrown when an operation is attempted on a transaction that has already been rolled back, or an attempt is made to commit the transaction and the transaction aborts.

System_CAPS_pubclassTransactionEventArgs

Provides data for the following transaction events: DistributedTransactionStarted, TransactionCompleted.

System_CAPS_pubclassTransactionException

The exception that is thrown when you attempt to do work on a transaction that cannot accept new work.

System_CAPS_pubclassTransactionInDoubtException

The exception that is thrown when an operation is attempted on a transaction that is in doubt, or an attempt is made to commit the transaction and the transaction becomes InDoubt.

System_CAPS_pubclassTransactionInformation

Provides additional information regarding a transaction.

System_CAPS_pubclassTransactionInterop

Facilitates interaction between System.Transactions and components that were previously written to interact with MSDTC, COM+, or System.EnterpriseServices. This class cannot be inherited.

System_CAPS_pubclassTransactionManager

Contains methods used for transaction management. This class cannot be inherited.

System_CAPS_pubclassTransactionManagerCommunicationException

The exception that is thrown when a resource manager cannot communicate with the transaction manager.

System_CAPS_pubclassTransactionPromotionException

The exception that is thrown when a promotion fails.

System_CAPS_pubclassTransactionScope

Makes a code block transactional. This class cannot be inherited.

StructureDescription
System_CAPS_pubstructureTransactionOptions

Contains additional information that specifies transaction behaviors.

InterfaceDescription
System_CAPS_pubinterfaceIDtcTransaction

Describes a DTC transaction.

System_CAPS_pubinterfaceIEnlistmentNotification

Describes an interface that a resource manager should implement to provide two phase commit notification callbacks for the transaction manager upon enlisting for participation.

System_CAPS_pubinterfaceIPromotableSinglePhaseNotification

Describes an object that acts as a commit delegate for a non-distributed transaction internal to a resource manager.

System_CAPS_pubinterfaceISimpleTransactionSuperior

Represents a transaction that is not a root transaction, but can be escalated to be managed by the MSDTC.

System_CAPS_pubinterfaceISinglePhaseNotification

Describes a resource object that supports single phase commit optimization to participate in a transaction.

System_CAPS_pubinterfaceITransactionPromoter

Describes a delegated transaction for an existing transaction that can be escalated to be managed by the MSDTC when needed.

DelegateDescription
System_CAPS_pubdelegateHostCurrentTransactionCallback

Provides a mechanism for the hosting environment to supply its own default notion of Current.

System_CAPS_pubdelegateTransactionCompletedEventHandler

Represents the method that handles the TransactionCompleted event of a Transaction class.

System_CAPS_pubdelegateTransactionStartedEventHandler

Represents the method that will handle the DistributedTransactionStarted event of a TransactionManager class.

EnumerationDescription
System_CAPS_pubenumDependentCloneOption

Controls what kind of dependent transaction to create.

System_CAPS_pubenumEnlistmentOptions

Determines whether the object should be enlisted during the prepare phase.

System_CAPS_pubenumEnterpriseServicesInteropOption

Specifies how distributed transactions interact with COM+ transactions.

System_CAPS_pubenumIsolationLevel

Specifies the isolation level of a transaction.

System_CAPS_pubenumTransactionScopeAsyncFlowOption

[Supported in the .NET Framework 4.5.1 and later versions]

Specifies whether transaction flow across thread continuations is enabled for TransactionScope.

System_CAPS_pubenumTransactionScopeOption

Provides additional options for creating a transaction scope.

System_CAPS_pubenumTransactionStatus

Describes the current status of a distributed transaction.

System_CAPS_importantImportant

You can only create applications using this namespace under the Windows 2000, Windows XP and Windows 2003 platforms. Creating a transaction under the Windows 98 and Windows ME platforms throws a PlatformNotSupportedException .

The System.Transactions infrastructure makes transactional programming simple and efficient throughout the platform by supporting transactions initiated in SQL Server, ADO.NET, MSMQ, and the Microsoft Distributed Transaction Coordinator (MSDTC). It provides both an explicit programming model based on the Transaction class, as well as an implicit programming model using the TransactionScope class, in which transactions are automatically managed by the infrastructure. It is highly recommended that you use the easier implicit model for development. To get started, please see the Implementing An Implicit Transaction Using Transaction Scope topic. For more information on writing a transactional application, see .

System.Transactions also provides types for you to implement a resource manager. The transaction manager native to the System.Transactions infrastructure allows volatile resources or a single durable resource enlistment to commit or roll back efficiently. For more information on implementing a resource manager, see Implementing A Resource Manager.

The transaction manager also transparently escalates local transactions to distributed transactions by coordinating through a disk-based transaction manager like the DTC, when an additional durable resource manager enlists itself with a transaction. There are two key ways that the System.Transactions infrastructure provides enhanced performance.

  • Dynamic Escalation, which means that the System.Transactions infrastructure only engages the MSDTC when it is actually required for a transaction. This area is covered in depth in the Transaction Management Escalation topic.

  • Promotable Enlistments, which allows a resource, such as a database, to take ownership of the transaction if it is the only entity participating in the transaction. Later, if needed, the System.Transactions infrastructure can still escalate the management of the transaction to MSDTC. This further reduces the chance of using the MSDTC. This area is covered in depth in the Optimization Using Single Phase Commit and Promotable Single Phase Notification topic.

System.Transactions defines three levels of trust that restrict access on the types of resources it exposes. Specifically, the System.Transactions assembly can be called by partially trusted code as it has been marked with the AllowPartiallyTrustedCallers attribute (APTCA). This attribute essentially removes the implicit LinkDemand for the FullTrust permission set that is otherwise automatically placed on each publicly accessible method in each type. However, some types and members still require stronger permissions.

The following is a list of types and members that are not callable by partially trusted code because they are decorated with the following declarative security attribute:

PermissionSetAttribute(SecurityAction.LinkDemand, Name := "FullTrust")

System.Transactions.Transaction.EnlistDurable

System.Transactions.Transaction.EnlistPromotableSinglePhase

System.Transactions.TransactionInterop

System.Transactions.TransactionManager.DistributedTransactionStarted

System.Transactions.TransactionManager.HostCurrentTransactionCallback

System.Transactions.TransactionManager.Reenlist

System.Transactions.TransactionManager.RecoveryComplete

System.Transactions.TransactionScope.TransactionScope (System.Transactions.Transaction,System.TimeSpan,System.Transactions.EnterpriseServicesInteropOption)

M:System.Transactions.TransactionScope.TransactionScope(System.Transactions.TransactionScopeOption,System.Transactions.TransactionOptions,System.Transactions.EnterpriseServicesInteropOption)

For more information on the various trust levels, see Security Trust Levels in Accessing Resources.

Core Development Technologies\Data Access\Transaction Processing\

For more information on how to use the System.Transactions namespace, you can consult the conceptual documentation Transaction Processing, located under the "Core Development Technologies\Data Access\Transaction Processing\" section in the documentation. Specifically, you can find more information in the following topics.

Features Provided By System.Transactions

Implementing A Resource Manager

Return to top
Show: