Skip to Main Content
COM & .NET Component Services
book

COM & .NET Component Services

by Juval Lowy
September 2001
Intermediate to advanced content levelIntermediate to advanced
384 pages
11h 59m
English
O'Reilly Media, Inc.
Content preview from COM & .NET Component Services

COM+ Transactions

You can configure your serviced component to use the five available COM+ transaction support options by using the Transaction attribute. The Transaction attribute’s constructor accepts an enum parameter of type TransactionOption , defined as:

public enum TransactionOption
{
   Disabled, 
   NotSupported, 
   Supported, 
   Required, 
   RequiresNew
}

For example, to configure your serviced component to require a transaction, use the TransactionOption.Required value:

[Transaction(TransactionOption.Required)]
public class MyComponent :ServicedComponent 
{...}

The five enum values of TransactionOption map to the five COM+ transaction support options discussed in Chapter 4.

When you use the Transaction attribute to mark your serviced component to use transactions, you implicitly set it to use JITA and require activity-based synchronization as well.

The Transaction attribute has an overloaded default constructor, which sets the transaction support to TransactionOption.Required. As a result, the following two statements are equivalent:

[Transaction]
[Transaction(TransactionOption.Required)]

Voting on the Transaction

Not surprisingly, you use the ContextUtil class to vote on the transaction’s outcome. ContextUtil has a static property of the enum type TransactionVote called MyTransactionVote. TransactionVote is defined as:

public enum TransactionVote {Abort,Commit}

Example 10-5 shows a transactional serviced component voting on its transaction outcome using ContextUtil. Note that the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Windows Server® 2008 Security Resource Kit

Windows Server® 2008 Security Resource Kit

Jesper M. Johansson

Publisher Resources

ISBN: 0596001037Supplemental ContentCatalog PageErrata