How do I enable MSDTC on SQL Server?

Sql ServerMsdtc

Sql Server Problem Overview


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?

Sql Server Solutions


Solution 1 - Sql Server

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

Solution 2 - Sql Server

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

Solution 3 - Sql Server

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.

Solution 4 - Sql Server

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.

Solution 5 - Sql Server

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.
http://www.sqldev.net/misc/DTCTest.htm">DTCTest</a> is a nice litt app that helps you to troubleshoot any other problems.

Solution 6 - Sql Server

@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.

Solution 7 - Sql Server

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).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDanView Question on Stackoverflow
Solution 1 - Sql ServerShiv SinghView Answer on Stackoverflow
Solution 2 - Sql ServerAndrew PetersView Answer on Stackoverflow
Solution 3 - Sql ServerDavy LandmanView Answer on Stackoverflow
Solution 4 - Sql ServerCameron CastilloView Answer on Stackoverflow
Solution 5 - Sql ServerLars MæhlumView Answer on Stackoverflow
Solution 6 - Sql ServerAndrew PetersView Answer on Stackoverflow
Solution 7 - Sql ServernmbellView Answer on Stackoverflow