Vishwamohan

Welcome to Vishwa's blog - Technology, Spirituality and More...

Communication with the underlying transaction

If you are using .NET 2.0 or higher Framework and System.Transactions Namespace to handle your transactions, chances are you may come across this error. In my application, I was using ADO.NET transaction, in stored procedure SQL Server transaction and now we decided to use a powerful transaction handler using .NET framework. If you are writing everything fresh, most likely you won’t like to mix different type of transaction handling mechanism. But what if you already have existing code and do not want to change, what to do. I tried to mix all the three kind of transactions, but it resulted in errors. Sometime, they timeout, sometime it just hanged and sometime it produced Microsoft Transaction Coordinator (MSDTC) error. So, how to resolve this problem? After spending several hours I found that one must follow following basic steps.


 

1. Import System.Transactions namespace in the class where you want to use distributed transaction

2. Make sure that this transaction mode is the root or mothers for all other type of transactions

3. Now you can add different type of transactions, it can be ADO.Net transaction, SQL Transaction or another child transaction using System.Transaction Namespace

4. After doing the first 3 steps, make sure you configure your machines with following options, otherwise you will come across the above error.

To fully enable MS DTC:

1. In Control Panel, open Administrative Tools, and then double-click Component Services.

2. In the left pane of Console Root, click Component Services, and then expand Computers.

3. Right-click My Computer, and then click Properties.

4. On the MSDTC tab, click Security Configuration.

5. Under Security Settings, select all of the check boxes.

6. Verify that the DTC Logon Account name is set to NT AUTHORITY\NetworkService.

 

 

 

If MSDTC still does not work then

1. Install MSDTC by going on command prompt and run following command: msdtc –install

2. After that you'll need to actually start the service

3. Make sure to go back in component services and follow the above step to enable MS DTC.

4. Windows Firewall –Make sure C:\Windows\System32\MSDTC.exe is added in Exceptions list of Windows Firewall

 

 

 

       If MSDTC still does not work, reboot the machine.

If you MSDTC still does not work, download the following tool and you can see where it is failing

                  http://www.microsoft.com/downloads/details.aspx?familyid=5E325025-4DCD-4658-A549-1D549AC17644&displaylang=en 

                  You need to make sure that these options are enabled on all participating machines (Web Server, App Server, SQL Server etc)


Example:
 
                 Public Sub MainMethod()
                       Dim tranOptions As New TransactionOptions()
                       tranOptions.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted
                       tranOptions.Timeout = New TimeSpan(0, 2, 0)
                       Using topMostScope As New TransactionScope(TransactionScopeOption.Required, tranOptions)
 
                            Call Method1UsingAdo_Net_Transaction()
                            Call Method2UsingSql_Server_Transaction()
                            Call Method3UsingChildTranScope()
 
                            topMostScope.Complete()
                       End Using
                End Sub
 
 

 

 

Comments (9) -

  • Registry C

    7/9/2009 10:39:53 AM | Reply

    I am doing something of the same interest and will be taking note on this .Thank

  • videochat

    7/25/2009 12:10:19 PM | Reply


    That is an astonishing piece of information that will be of great use for my friend.  

  • San Diego Web Design

    8/13/2009 1:39:47 PM | Reply

    I just couldn't leave your website before saying that I really enjoyed the quality information you offer. Will be back often to check up on new stuff you post!

  • Medicare Advantage

    8/13/2009 1:39:50 PM | Reply

    Me and my friend were actully discussing this the other day! Now I know that I was right. lol!

  • Boston A

    9/2/2009 9:15:24 AM | Reply

    That is some inspirational stuff. Never knew that opinions could be this varied. Thanks for all the enthusiasm to offer such helpful information here.

  • FUN

    2/10/2010 4:21:17 PM | Reply

    Nice one - Thanks for sharing dude.

  • Fatcow Coupon

    2/26/2010 12:57:12 PM | Reply

    Should I get a VPS? Right now I am using ixwebhosting but they keep turning off my websites due to high server overload. Im getting about 2,000 unique views a day. What brand should I get?

  • Property Bulgaria

    3/19/2010 2:48:06 PM | Reply

    I like the blog, but could not find how to subscribe to receive the updates by email.

Loading