. NET Framework Class Library
System.Transactions namespaces
Note: This namespace is new in the. NET Framework version 2.0.
Classes that are included with the System.Transactions namespace can write their own transaction applications and resource managers. Specifically, you can create and participate in (with one or more participants) local or distributed transactions.
Important matters:
You can only use this namespace to create applications on Windows 2000, Windows XP, and Windows 2003 platforms. Creating Transactions on Windows 98 and Windows ME platforms can cause platformnotsupportedexception.
The System.Transactions infrastructure enables transaction programming to be simple and efficient across the platform by supporting transactions that are initiated in SQL Server, Ado.net, MSMQ, and Microsoft Distributed Transaction Coordinator (MSDTC). It provides an explicit programming model based on the Transaction class and also provides an implicit programming model that uses the TransactionScope class, in which transactions are automatically managed by the infrastructure. It is highly recommended to develop using a more convenient implicit model. To begin, see Implementing an implicit Transaction topic with a transaction scope. For more information about writing a transactional application, see Writing a transactional application.
System.Transactions also provides some types that you can use to implement a resource manager. The native transaction manager using the System.Transactions infrastructure can effectively commit or rollback a mutable resource or a single persistent resource enlistment. For more information about implementing the Resource Manager, see Implementing a resource manager.
When another persistent resource manager enlists to a transaction, the transaction manager also transparently upgrades the local transaction to a distributed transaction through the coordinated use of a disk-based transaction manager, such as DTC. There are two key ways the System.Transactions infrastructure provides enhanced performance.
Dynamic escalation, that is, the System.Transactions infrastructure uses MSDTC only when the transaction actually requires MSDTC. This section is covered in detail in the Transaction Management upgrade topic.
You can upgrade registrations and allow a resource, such as a database, to take ownership of a transaction if it is the only entity that participates in the transaction. Later, if necessary, the System.Transactions infrastructure can still give transaction management to MSDTC. This further reduces the chances of using MSDTC. This section is covered in detail in the optimization topics using single phase commit and upgradeable single phase notifications.
System.Transactions defines three trust levels that restrict access to the types of resources that they expose. Specifically, if the System.Transactions assembly has been marked with the AllowPartiallyTrustedCallers attribute (APTCA), it can be called by partially trusted code. This property is essentially an implicit LinkDemand that removes the FullTrust permission set, and in other cases LinkDemand is automatically placed on each public accessible method of each type. However, some types and members still require stronger permissions.