115

Is this even a valid question? I have a .NET Windows app that is using MSTDC and it is throwing an exception:

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 ---> System.Runtime.InteropServices.COMException (0x8004D024): The transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D024) at System.Transactions.Oletx.IDtcProxyShimFactory.ReceiveTransaction(UInt32 propgationTokenSize, Byte[] propgationToken, IntPtr managedIdentifier, Guid& transactionIdentifier, OletxTransactionIsolationLevel& isolationLevel, ITransactionShim& transactionShim)....

I followed the Kbalertz guide to enable MSDTC on the PC on which the app is installed, but the error still occurs.

I was wondering if this was a database issue? If so, how can I resolve it?

slugster
  • 49,403
  • 14
  • 95
  • 145
Dan
  • 29,100
  • 43
  • 148
  • 207
  • If the mentioned solutions don't solve the issue, check [this link](http://stackoverflow.com/questions/10346367/mvc-3-the-msdtc-transaction-manager-was-unable-to-pull-the-transaction-from-th) – Shahab J Dec 07 '16 at 23:00

7 Answers7

139

Use this for windows Server 2008 r2 and Windows Server 2012 R2

  1. Click Start, click Run, type dcomcnfg and then click OK to open Component Services.

  2. In the console tree, click to expand Component Services, click to expand Computers, click to expand My Computer, click to expand Distributed Transaction Coordinator and then click Local DTC.

  3. Right click Local DTC and click Properties to display the Local DTC Properties dialog box.

  4. Click the Security tab.

  5. Check mark "Network DTC Access" checkbox.

  6. Finally check mark "Allow Inbound" and "Allow Outbound" checkboxes.

  7. Click Apply, OK.

  8. A message will pop up about restarting the service.

  9. Click OK and That's all.

Reference : https://msdn.microsoft.com/en-us/library/dd327979.aspx

Note: Sometimes the network firewall on the Local Computer or the Server could interrupt your connection so make sure you create rules to "Allow Inbound" and "Allow Outbound" connection for C:\Windows\System32\msdtc.exe

Shiv Singh
  • 6,939
  • 3
  • 40
  • 50
  • The correct path of `msdtc.exe` is is: `c:\windows\system32\msdtc.exe` – firepol Oct 19 '18 at 05:49
  • 1
    There seems to be a bug where these properties do not stick when set through the UI, at least on clustered Server 2016 nodes. The solution is to set these properties manually in the registry: `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSDTC\Security`. More info on the properties [here](https://support.microsoft.com/en-us/help/899191/new-functionality-in-the-distributed-transaction-coordinator-service-i). – Paul Nov 02 '18 at 16:39
104

Do you even need MSDTC? The escalation you're experiencing is often caused by creating multiple connections within a single TransactionScope.

If you do need it then you need to enable it as outlined in the error message. On XP:

  • Go to Administrative Tools -> Component Services
  • Expand Component Services -> Computers ->
  • Right-click -> Properties -> MSDTC tab
  • Hit the Security Configuration button
Andrew Peters
  • 11,135
  • 4
  • 37
  • 34
  • 2
    Also in windows firewall I opened port 135 TCP and added c:\windows\msdtc.exe as an exception – Sameer Alibhai Mar 19 '10 at 19:45
  • 21
    Thanks for the comment about the error being caused by creating multiple connections within a single TransactionScope. I was getting the error and that was exactly the problem. I didn't want to use the MSDTC, so I found the errant new connection and reused an existing one. Thanks! – Jim McKeeth Apr 19 '10 at 23:58
  • 10
    I'm on windows 7 and 8, and there's only a "Default Coordinator" section. Where can I get to the security configuration that you're talking about? – qdev76 Mar 06 '14 at 18:27
  • 2
    1) Right click on Local DTC and choose properties 2) Open the security tab 3) Check at least Network DTC Access, Allow Remote Clients and Allow Inbound. – Rob Sedgwick Jun 04 '15 at 09:58
21

I've found that the best way to debug is to use the microsoft tool called DTCPing

  1. Copy the file to both the server (DB) and the client (Application server/client pc)
    • Start it at the server and the client
    • At the server: fill in the client netbios computer name and try to setup a DTC connection
    • Restart both applications.
    • At the client: fill in the server netbios computer name and try to setup a DTC connection

I've had my fare deal of problems in our old company network, and I've got a few tips:

  • if you get the error message "Gethostbyname failed" it means the computer can not find the other computer by its netbios name. The server could for instance resolve and ping the client, but that works on a DNS level. Not on a netbios lookup level. Using WINS servers or changing the LMHOST (dirty) will solve this problem.
  • if you get an error "Acces Denied", the security settings don't match. You should compare the security tab for the msdtc and get the server and client to match. One other thing to look at is the RestrictRemoteClients value. Depending on your OS version and more importantly the Service Pack, this value can be different.
  • Other connection problems:
    • The firewall between the server and the client must allow communication over port 135. And more importantly the connection can be initiated from both sites (I had a lot of problems with the firewall people in my company because they assumed only the server would open an connection on to that port)
    • The protocol returns a random port to connect to for the real transaction communication. Firewall people don't like that, they like to restrict the ports to a certain range. You can restrict the RPC dynamic port generation to a certain range using the keys as described in How to configure RPC dynamic port allocation to work with firewalls.

In my experience, if the DTCPing is able to setup a DTC connection initiated from the client and initiated from the server, your transactions are not the problem any more.

Davy Landman
  • 15,109
  • 6
  • 49
  • 73
7

Can also see here on how to turn on MSDTC from the Control Panel's services.msc.

On the server where the trigger resides, you need to turn the MSDTC service on. You can this by clicking START > SETTINGS > CONTROL PANEL > ADMINISTRATIVE TOOLS > SERVICES. Find the service called 'Distributed Transaction Coordinator' and RIGHT CLICK (on it and select) > Start.

Bruno Brant
  • 8,226
  • 7
  • 45
  • 90
Cameron Castillo
  • 2,712
  • 10
  • 47
  • 77
4

MSDTC must be enabled on both systems, both server and client.
Also, make sure that there isn't a firewall between the systems that blocks RPC.
DTCTest is a nice litt app that helps you to troubleshoot any other problems.

Lars Mæhlum
  • 6,074
  • 3
  • 28
  • 32
  • I think this is the new location https://www.microsoft.com/en-us/download/details.aspx?id=30746 – Air2 Apr 09 '18 at 14:55
4

@Dan,

Do I not need msdtc enabled for transactions to work?

Only distributed transactions - Those that involve more than a single connection. Make doubly sure you are only opening a single connection within the transaction and it won't escalate - Performance will be much better too.

Andrew Peters
  • 11,135
  • 4
  • 37
  • 34
  • Do I not need msdtc enabled for transactions to work? Either way, multiple connections are not being made as far as I'm aware. I've already run those steps on the client PC, are you saying I should also do those steps on the database server? – Dan Aug 11 '08 at 12:51
  • @Dan, you are not required to enable DTC if you are using ado.net transactions. You are required to enable MSDTC on the server only if you are using Distributed transactions – Niraj Feb 17 '11 at 12:32
1

MSDTC can be configured with MsDtc PowerShell module, e.g.:

# Import the module
Import-Module -Name MsDtc

# Set the DTC config
$dtcNetworkSetting = @{
    DtcName                           = 'Local'
    AuthenticationLevel               = 'NoAuth'
    InboundTransactionsEnabled        = $true
    OutboundTransactionsEnabled       = $true
    RemoteClientAccessEnabled         = $true
    RemoteAdministrationAccessEnabled = $true
    XATransactionsEnabled             = $false
    LUTransactionsEnabled             = $true
}
Set-DtcNetworkSetting @dtcNetworkSetting

# Restart the MsDtc service
Get-Service -Name MsDtc | Restart-Service

Run on each of the machines that will be supporting the distributed transactions (i.e. where the MSDTC service is running).

nmbell
  • 451
  • 3
  • 7