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
You need to make sure that these options are enabled on all participating machines (Web Server, App Server, SQL Server etc)
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)