views:

1922

answers:

4

Hi,

in our current project we are using ADO.NET Entity Framework as data layer for the application. There are some tasks which require to run in a transaction because there's a lot of work to do in the database. I am using a TransactionScope to surround those tasks.

using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.RequiresNew))
{
    // Do something...
    transactionScope.Complete();
}

The problem is as soon as i am using an TransactionScope an exception occurs:

*System.Data.EntityException: The underlying provider failed on Open. ---> System.Transactions.TransactionManagerCommunicationException: Communication with the underlying transaction manager has failed. ---> System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.*

It seems that this error has to do something with the MSDTC (Microsoft Distributed Transaction Coordinator). When i change the security configuration of MSDTC another exception is thrown:

System.Data.EntityException: The underlying provider failed on Open. ---> System.Transactions.TransactionManagerCommunicationException: Network access for Distributed Transaction Manager (MSDTC) has been disabled. Please enable DTC for network access in the security configuration for MSDTC using the Component Services Administrative tool.

However MSDTC is configured, the TransactionScope will cause an error. Does somebody know whats going wrong here?

+1  A: 
Nikolay R
Alexander
A: 

Hmm, it seems to work when i change the TransactionScopeOption to "Suppress":

using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Suppress))
{
    ...
}

Does everyone know why?

Alexander
I think it does not use transaction at all in this case but I'm not sure.
Nikolay R
Yes, this option indicates that it should not take part in the transaction.
Binoj Antony
I'm getting the same error, but there's no way this is the best answer.
Rory MacLeod
A: 

This means it is suppressing any Transaction that might be in effect currently when you enter your code block, so any updates your code makes will not rollback if the outer "ambient" transaction decides to rollback.

SpockMonster
A: 

This is the article we used in resolving our own, similar issue:

Troubleshooting Problems with MSDTC

This is basically an addendum to Nikolay R's answer. He already covered some of the suggestions listed in the article.

Note: The article is part of the Biztalk documentation, but it can apply to anything using MSDTC.

John Allers