How to Write Atomic Transactions in .NET
page 4 of 7
by Keyvan Nayyeri
Feedback
Average Rating: 
Views (Total / Last 10 Days): 37432/ 51

Register Component Service

After creating my simple class, I needed to set its transaction behavior.  I can do this via an attribute in my code or via Component Services MMC snap-in.

There are several options for TransactionOption enumerator, but I chose RequiresNew to create a new transaction with my component.  All available options are:

·         Disabled: This does not use a current transaction, but also will not create a new one if it is not available.

·         NotSupported: The component will be created without any control available on it.

·         Required: This uses a current transaction or creates a new one if it is not available.

·         RequiresNew: This always creates a new transaction even if a current transaction is available.

·         Supported: This uses a current transaction, but will not create a new one if it is not available.

I also set my ApplicationAccessControl for assembly attribute to true.

Listing 5

namespace AtomicTransactions
{
    [assembly: ApplicationAccessControl(true)]
    [Transaction(TransactionOption.RequiresNew)]
    public class MyTransaction  : ServicedComponent
    {

Next, I built my assembly and made it COM Visible. I also created a strong name for this assembly.  Finally, I compiled my Class Library and registered it as a Component Service via Visual Studio command prompt:

C:\AtomicTransactions\bin\Debug>regsvcs AtomicTransactions.dll

Figure 3


View Entire Article

User Comments

Title: ASAS   
Name: ASAS
Date: 2012-08-01 7:53:47 AM
Comment:
asd
Title: Very Gud   
Name: Soby
Date: 2007-06-09 7:26:03 AM
Comment:
This is very Help for me

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-16 6:51:19 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search