How do I enable MSDTC on SQL Server?
Asked Answered
N

7

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?

Nigercongo answered 11/8, 2008 at 11:57 Comment(1)
If the mentioned solutions don't solve the issue, check this linkJape
S
140

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

Smothers answered 3/12, 2014 at 4:54 Comment(2)
The correct path of msdtc.exe is is: c:\windows\system32\msdtc.exeReagan
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.Hadlee
U
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
Urba answered 11/8, 2008 at 12:10 Comment(4)
Also in windows firewall I opened port 135 TCP and added c:\windows\msdtc.exe as an exceptionSexy
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!Repeat
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?Tomtit
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.Aldin
B
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.

Barbican answered 26/1, 2009 at 8:49 Comment(0)
C
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.

Conclave answered 3/6, 2014 at 7:35 Comment(0)
R
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.

Rajasthani answered 11/8, 2008 at 12:4 Comment(1)
I think this is the new location microsoft.com/en-us/download/details.aspx?id=30746Gerfen
U
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.

Urba answered 11/8, 2008 at 23:2 Comment(2)
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?Nigercongo
@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 transactionsVirgulate
B
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).

Banker answered 7/5, 2021 at 4:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.