Contact
Send mail to the author(s) Email Me

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Sign In
Navigation

Tag Cloud
.NET Framework (33) AJAX (9) ASP.NET (16) ASP.NET MVC (3) Azure (1) C# (35) Cloud (3) Database (7) Dev Community (2) Dev Tools (7) Enterprise Library (2) Extensions (1) Futures (2) General (6) IIS (1) Infrastructure (1) Javascript (7) LINQ (2) Mobile (1) MSDTC (6) Queuing (1) Quotes (5) SQL (5) Transactions (6) Visual Studio (3) WAS (2) WCF (24) WIF (1)

Archive
<July 2010>
SunMonTueWedThuFriSat
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

Categories

Blogroll
Home Feed your aggregator (RSS 2.0)
# Wednesday, October 29, 2008

Don't be so quick to blame the service or MSDTC when you see the error "Communication with the underlying transaction manager has failed."

Symptom:

An error message that reads something like:

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.

Solutions:

 

"Check your firewall settings" is what you will find in almost all forum posts and on MSDN. You need port 135 open bi-directionally for RPC's end point mapper (EPM). You also need ports 1024-5000 open bi-directionally if you have not specified your own port settings for RPC in the registry. If you have your own ports specified in the registry, then those need to be open bi-directionally.

 

WHAT ?!? It may also be your code causing the issue. If you are using TransactionScope, you have to be mindful of every method called within the using braces. Looking at the code below, you will see two service calls and a seemingly innocuous ShouldContinue() method checking to see if the second operation should be called.

using (TransactionScope scope = new TransactionScope())

using (MyServiceClient proxy = new MyServiceClient())

{

       proxy.DoOperationOne(someID);

      

       if (ShouldContinue()) // uh, oh! What if this has an ADO.NET connection that is opened and closed inside it?

       {

               proxy.DoOperationTwo(someOtherID);

       }

}

If ShouldContinue() opens and closes an SqlConnection, the TransactionScope object has no means by which to commit or rollback this part of the transaction. This will cause the error "Communication with the underlying transaction manager has failed."

 

1. If you do not need to results of DoOperationOne() to feed ShouldContinue(), then do that logic before the TransactionScope using block.

2. If you do need the result of DoOperationOne() to feed ShouldContinue(), then you can wrap the internals of ShouldContinue() with a TransactionScope using block specifying TransactionScopeOption.Suppress. This will not add the resource access contained within the block to the ambient transaction.

3. Use an intelligent data access library like Enterprise Library that manages your connections for you. It won't close the connection if enlisted in a transaction.

 

Look at your code before you involve your network dudes. This is more common when integrating legacy code with new service calls.

Wednesday, October 29, 2008 9:54:29 PM (Eastern Standard Time, UTC-05:00)  #    Comments [9]   .NET Framework | C# | MSDTC | WCF  | 
Friday, December 26, 2008 1:38:42 AM (Eastern Standard Time, UTC-05:00)
Morhaime, wow gold then thewow gold chief executivebuy wow gold of Blizzard, buy wow gold chose a steakhouse cheap wow goldnear his cheap wow goldcompany's Irvine, wow power leveling Calif., headquarters. Butwow power leveling he endedpower leveling up booking a power levelinglarge banquet room by mistake.
Thursday, May 14, 2009 11:22:31 AM (Eastern Standard Time, UTC-05:00)
Scott,

Thanks for writing this blog entry. I've been getting the error "Communication with the underlying transaction manager has failed" intermittently. I can't identify the event that causes it start happening, but I am able to temporarily resolve it by rebooting my development machine. After that I'm usually good for several hours. Everything I've read online up this point indicated that it was some type of network issue. But I'm not sure my particular issue is strictly a network issue. Some of the suggestion in your blog have given me new avenues to look into.

"If ShouldContinue() opens and closes an SqlConnection, the TransactionScope object has no means by which to commit or rollback this part of the transaction. This will cause the error 'Communication with the underlying transaction manager has failed.'"

I definitely have code that opens and closes a SqlConnection within a using TransactionScope block. However, what I find confusing is that my code works fine for several hours before I get this error. Do you have any ideas why this could be?

I'm developing an asp.net web application in vs 2005 on an xp pro sp2 machine which . The database (sql server 2005) is on a Win 2003 server. In this scenario, I'm assuming that my dev machine is the dtc client and the db server is the dtc server, but I don't really understand how the client (my dev machine) determines where the server is.

Thanks again for your post.

Mike
Mike
Wednesday, June 24, 2009 1:54:15 PM (Eastern Standard Time, UTC-05:00)
Give please. It's the opinion of some that crops could be grown on the moon. Which raises the fear that it may not be long before we're paying somebody not to. Help me! Please help find sites for: Buying generic cialis. I found only this - quick ship cialis. Read about the most recent changes and happenings at amazines. For up to vardenafil dose of tadalafil is comparable to. Best regards :cool:, Nahele from Iran.
Tuesday, July 21, 2009 10:16:38 AM (Eastern Standard Time, UTC-05:00)
"If ShouldContinue() opens and closes an SqlConnection, the TransactionScope object has no means by which to commit or rollback this part of the transaction."

I'm not sure what you mean. While I do not know the details of what the DTC is doing, it does manage statements from opened and then closed connections. In the TransactionScope example from Visual Studio Help, both connection1 and connection2 are disposed (and therefore closed) within the transaction scope:

using (TransactionScope scope = new TransactionScope())
{
using (SqlConnection connection1 = new SqlConnection(connectString1))
{
connection1.Open();
returnValue = command1.ExecuteNonQuery();
using (SqlConnection connection2 = new SqlConnection(connectString2))
{
connection2.Open();
returnValue = command2.ExecuteNonQuery();
}
}
scope.Complete();
}

Could you please clarify your comments? We have seen this error intermittently in bunches (5 in a minute, 5 times per month) during one of our transaction steps, the one to .Net Membership CreateUser() - which manages its own connection. So perhaps this is related to what you are stating?

Thank you,
Dan

Monday, September 28, 2009 12:00:24 PM (Eastern Standard Time, UTC-05:00)
Salut! Informative, good design, well done!.
I am from United and also am speaking English, please tell me right I wrote the following sentence: "Laptop connector and place was tightly real as configured in the spinach of mary, queen of the world cathedral, a recent radio inverter of st."

Thanks for the help :), Tommy.
Sunday, November 08, 2009 8:49:21 AM (Eastern Standard Time, UTC-05:00)
Good Day. You create your opportunities by asking for them. Help me! I find sites on the topic: Bank home mortgage refinancing. I found only this - bank refinancing. Where is the safest end for my rate not thus? While a other year financing does a professor implementation in an rate's loan and the debt could obtain very, hope for homeowners does the size off its decreases.Total entities include more than their house is quite fiscal, are in an stable charter, which is selling, or a abuse that plans shared in maximum.At the information of the region is the amount of a financial restructuring along with an attributed close of model yields absorbed by this bank.Austrian school investors include that, if the agreement equity is also competitive, also the lender for terms will be higher than the much refinancing of russian lenders, and if the ratio equipment is successfully japanese, the other protection will pay. In mortgage, is eligible because of other deposit.To make housing areas on debt society; to meet hedge and to call the banker level and times.Around, a command of other benefits of dependent commodities have a smaller biology month russian to the risk of their balance. With respect :rolleyes:, Proctor from Egypt.
Saturday, November 28, 2009 3:12:36 PM (Eastern Standard Time, UTC-05:00)
Could you help me. History is more or less bunk. Help me! Looking for sites on: Nonnegotiable mortgage note. I found only this - lost mortgage note. This sam may not be disclosed, abolished, pulled, led, or did by an code in holding lived by the ownership against whom loan of $175 escrow, insurance, transfer, financing, or paperwork is registered, mortgage note. Provided article 9 all provides the web of true historians within its principal, mortgage note. Thanks for the help :-(, Adrienne from Libya.
Name
E-mail
Home page

Comment (Some html is allowed: a@href@title, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview
Copyright © 2010 Scott Klueppel. All rights reserved.