C# MSDTC - 与底层事务管理器的通信失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11356077/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MSDTC - Communication with the underlying transaction manager has failed
提问by M005
I am getting error:
我收到错误:
communication with the underlying transaction manager has failed
与底层事务管理器的通信失败
when I am trying to run my application from visual studio 2010. I have search on google for this problem, I have tried all possible solutions to resolve this error.
当我尝试从 Visual Studio 2010 运行我的应用程序时。我在谷歌上搜索过这个问题,我已经尝试了所有可能的解决方案来解决这个错误。
Here i have made change in my DTC properties.
在这里,我对 DTC 属性进行了更改。
-- Network DTC Access
-- Allow Inbound
-- Allow Outbound
-- Allow Remote Administrator
-- Allow Remote Clients
-- No Authentication Required
-- Enable XA Transaction
-- Enable SNA LU 6.2 Transaction
Please let me know, if anyone knows the solution for this problem.
请让我知道,如果有人知道这个问题的解决方案。
Thanks Manoj Sitapara
感谢 Manoj Sitapara
采纳答案by Tuyen Nguyen
Try allowing DTC to communicate through Firewall.
尝试允许 DTC 通过防火墙进行通信。


回答by Marcel N.
Download DTCPingon all computers involved in the distributed transaction and run it.
DTCPing在参与分布式事务的所有计算机上下载并运行它。
Most of the times it will give you the exact error and what's wrong (like identical CID's), etc.
大多数情况下,它会给您确切的错误和错误(如相同的 CID)等。
Possible reasons:
可能的原因:
- Computers are not reachable by NetBIOS name. In this case you either have to adjust their
hostsfile to add mappings IP/hostname or, if in a domain, add DNS aliases for them. - The servers are VMs and they were cloned from the same VM instance. In this case the MSDTC CIDs are identical and you need to install/reinstall MSDTC (DTCping will tell you this).
- NetBIOS 名称无法访问计算机。在这种情况下,您必须调整他们的
hosts文件以添加映射 IP/主机名,或者如果在域中,则为它们添加 DNS 别名。 - 服务器是虚拟机,它们是从同一个虚拟机实例克隆的。在这种情况下,MSDTC CID 是相同的,您需要安装/重新安装 MSDTC(DTCping 会告诉您这一点)。
回答by Greg Bray
Check the MSDTC troubleshooting guide, which lists duplicate CIDs as a potential issue. You can use the following Powershell script to detect duplicate CIDs and reinstall MSDTC if needed using WinRM:
查看MSDTC 故障排除指南,其中将重复的 CID 列为潜在问题。您可以使用以下 Powershell 脚本来检测重复的 CID,并在需要时使用 WinRM 重新安装 MSDTC:
write-host "Checking for duplicate CIDs and reinstalling MSDTC if needed."
$servers = "server1","server2","server3"
$CIDs = Invoke-Command -ComputerName $servers -ScriptBlock { gci Microsoft.PowerShell.Core\Registry::HKEY_CLASSES_ROOT\CID | foreach { $_.Name } | Out-String -Stream } #Array of all CIDs on all servers
$UniqueCIDs = $CIDs | select -Unique
if($CIDs.Length -eq $UniqueCIDs.Length){
Write-Output "All CIDs are unique, so we don't need to reinstall MSDTC"
} else {
Write-Output "Found duplicate CIDs, so we need to reinstall MSDTC on all VMs"
Invoke-Command -ComputerName $servers -ScriptBlock {
write-output "`r`nUninstalling MSDTC to regenerate CIDs on $env:computername"
msdtc -uninstall | Write-Output
sleep 25 #wait for previous command to finish
write-output "`r`nReinstalling MSDTC to regenerate CIDs on $env:computername"
msdtc -install | Write-Output
sleep 25 #wait for previous command to finish
write-output "`r`nSetting MSDTC service to automatic on $env:computername"
Set-Service msdtc -startuptype "auto"
write-output "`r`nWARNING: $env:computername may need to be restarted for changes to take effect."
}
}
回答by mandersen
I got the failed communication error while trying to set up DTC and MSMQ on a cluster. In my case the underlying error was "Ran out of memory." I was able to send transactional messages from the cluster to another server, but not back from that server to the cluster. My service would throw this exception:
尝试在群集上设置 DTC 和 MSMQ时出现通信失败错误。在我的情况下,潜在的错误是“内存不足”。我能够将事务消息从集群发送到另一台服务器,但不能从该服务器发送回集群。我的服务会抛出这个异常:
System.Transactions.TransactionAbortedException: The transaction has aborted.
---> System.Transactions.TransactionManagerCommunicationException: Communication
with the underlying transaction manager has failed. --->
System.Runtime.InteropServices.COMException: Ran out of memory (Exception from HRESULT: 0x80000002)
This article had the very obscure solution: http://www.nervousadmin.com/category/microsoft/windows/dtc/
这篇文章有一个非常晦涩的解决方案:http: //www.nervousadmin.com/category/microsoft/windows/dtc/
To summarize:
总结一下:
There is a guid in the registry for the key ClusterDefaultResource under HKLM\Cluster\ResourceTypes\Distributed Transaction Coordinator that needs to align with the guid argument on the DTC service's path to executable.
HKLM\Cluster\ResourceTypes\Distributed Transaction Coordinator 下的注册表项 ClusterDefaultResource 有一个 guid,它需要与 DTC 服务的可执行路径上的 guid 参数保持一致。
Another symptom of this issue is that you would get an out of memory error if you try to access the DTC properties via the Component Services management console. Look in the console tree under Component Services/Computers/My Computer/Distributed Transaction Coordinator and right click on each of the DTCs listed there. This will throw the error if your guids are not aligned.
此问题的另一个症状是,如果您尝试通过组件服务管理控制台访问 DTC 属性,则会出现内存不足错误。查看组件服务/计算机/我的电脑/分布式事务协调器下的控制台树,然后右键单击其中列出的每个 DTC。如果您的 guid 未对齐,这将引发错误。
- Open services.msc. Find the Distributed Transaction Coordinator (if there are two, you're looking for the one with the guid in its name)
- Open that DTC's properties. Copy the guid from the 'path to executable'
- Open regedit. Find HKLM\Cluster\ResourceTypes\Distributed Transaction Coordinator
- Compare the ClusterDefaultResource value to the guid you've copied. If they are different, the next step should fix things. If not, this isn't your answer.
- Back up the current value. Edit the ClusterDefaultResource property: paste the guid you copied from the services.msc DTC properties. You will need to do this on each node in your cluster.
- With luck, this has solved your problem.
- 打开 services.msc。找到分布式事务协调器(如果有两个,您正在寻找名称中带有 guid 的那个)
- 打开该 DTC 的属性。从“可执行文件的路径”中复制 guid
- 打开注册表。找到 HKLM\Cluster\ResourceTypes\Distributed Transaction Coordinator
- 将 ClusterDefaultResource 值与您复制的 guid 进行比较。如果它们不同,下一步应该解决问题。如果没有,这不是你的答案。
- 备份当前值。编辑 ClusterDefaultResource 属性:粘贴您从 services.msc DTC 属性复制的 guid。您需要在集群中的每个节点上执行此操作。
- 幸运的是,这已经解决了您的问题。

