101

I'm using SQL Server and ASP.NET. I have the following function:

Using js = daoFactory.CreateJoinScope()
    Using tran = New Transactions.TransactionScope()
        '...
        tran.Complete()
    End Using
End Using

However, the following exception is thrown:

The transaction manager has disabled its support for remote/network transactions.

Description of JoinScope:

Public Class JoinScope
    Implements IJoinScope
    Implements IDisposable
    '...
End Class

I have worked this way in another application with the same environment without a problem, but here I have this problem. What could I do to fix the issue?

Dale K
  • 25,246
  • 15
  • 42
  • 71
Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175
  • I did the steps that Magnus suggested first to make sure that I had all bases covered, so to speak, and then managed to get an error suggesting that set I enable clr in SQL Server, and that worked for me. https://msdn.microsoft.com/en-us/library/ms131048.aspx – Lee Mar 04 '17 at 12:56

10 Answers10

166

Make sure that the "Distributed Transaction Coordinator" Service is running on both database and client. Also make sure you check "Network DTC Access", "Allow Remote Client", "Allow Inbound/Outbound" and "Enable TIP".

To enable Network DTC Access for MS DTC transactions

  1. Open the Component Services snap-in.

    To open Component Services, click Start. In the search box, type dcomcnfg, and then press ENTER.

  2. Expand the console tree to locate the DTC (for example, Local DTC) for which you want to enable Network MS DTC Access.

  3. On the Action menu, click Properties.

  4. Click the Security tab and make the following changes: In Security Settings, select the Network DTC Access check box.

    In Transaction Manager Communication, select the Allow Inbound and Allow Outbound check boxes.

Magnus
  • 45,362
  • 8
  • 80
  • 118
  • 3
    Thank you, Magnus. It must be a setting of the application, because this type of transaction worked with the same computers, which means this issue is not machine-related. – Lajos Arpad Apr 12 '12 at 20:39
  • Yes, I did. It throws the same exception. – Lajos Arpad Apr 12 '12 at 20:43
  • I guess it has to do with what you are actually doing inside the TransactionScope. – Magnus Apr 12 '12 at 20:45
  • Also, I need the join scope, because I want this transaction to be sent as a single request to the database server. – Lajos Arpad Apr 12 '12 at 20:46
  • I'm doing an insertion of a user. A validation is the first step. If the user is valid, it will be inserted and a batch insertion will happen to a table which has a foreign key to the table which contains the users. – Lajos Arpad Apr 12 '12 at 20:47
  • The same was done in another application, but with other tables. It was successful in the other application. I guess something is missing from the web config, or the issue might be cause by application-level settings or the lack of them. – Lajos Arpad Apr 12 '12 at 20:49
  • 17
    make sure you use the same open connection for all the database calls inside the transaction. – Magnus Apr 12 '12 at 20:50
  • I think that's the problem. I will make a few tests and will let you know about the results. (It's very probable that I will upvote you and accept your answer) – Lajos Arpad Apr 12 '12 at 20:53
  • Yes, the issue was exactly that. A module was old, a version before the support was made for this kind of transaction. It works now as expected. Thank you very much. I'll upvote and accept your answer. Thank you again. – Lajos Arpad Apr 12 '12 at 21:07
  • This worked for my OS (Server 2008). Depending upon your OS you may need to follow this procedure instead: https://social.msdn.microsoft.com/Forums/en-US/7172223f-acbe-4472-8cdf-feec80fd2e64/the-partner-transaction-manager-has-disabled-its-support-for-remotenetwork-transactions?forum=adodotnetdataproviders – Jeff Davis Nov 06 '14 at 15:58
  • When I faced this error I also had to include SET XACT_ABORT ON on my stored procedure. The following link explains https://learn.microsoft.com/en-us/sql/t-sql/statements/set-xact-abort-transact-sql – Lucas May 31 '17 at 19:54
  • Thanks for this answer. The part left out of Microsoft's documentation was that you needed to enable Network DTC access on the database server too. This answer resolved the issue for me. – Lews Therin Jul 25 '17 at 13:48
  • This answer worked for me, but I had to restart the server after making the change before things started working. – deadlydog Mar 22 '19 at 23:03
  • 1
    10 years later, we're still dealing with this problem, and your solution was right on point. Note that this DTC Settings change has to be made on the remote server too, not just on the client end. – Bryan Williams Sep 30 '22 at 15:07
16

I had a store procedure that call another store Procedure in "linked server".when I execute it in ssms it was ok,but when I call it in application(By Entity Framework),I got this error. This article helped me and I used this script:

EXEC sp_serveroption @server = 'LinkedServer IP or Name',@optname = 'remote proc transaction promotion', @optvalue = 'false' ;

for more detail look at this: Linked server : The partner transaction manager has disabled its support for remote/network transactions

Amirhossein Yari
  • 2,054
  • 3
  • 26
  • 38
  • 2
    A link to a solution is welcome, but please ensure your answer is useful without it: [add context around the link](//meta.stackexchange.com/a/8259) so your fellow users will have some idea what it is and why it’s there, then quote the most relevant part of the page you're linking to in case the target page is unavailable. [Answers that are little more than a link may be deleted.](//stackoverflow.com/help/deleted-answers) – Petter Friberg Jun 07 '17 at 09:41
  • 1
    This resolved my issue, so thank you for providing this. I don't know why it got a -1 vote, since it worked to rectify my specific problem. – Boyd P Oct 12 '17 at 17:33
13

In my scenario, the exception was being thrown because I was trying to create a new connection instance within a TransactionScope on an already existing connection:

Example:

void someFunction()
{
    using (var db = new DBContext(GetConnectionString()))
    {
        using (var transaction = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted }))
        {
            someOtherFunction(); // This function opens a new connection within this transaction, causing the exception.
        }
    }
}

void someOtherFunction()
{
    using (var db = new DBContext(GetConnectionString()))
    {
        db.Whatever // <- Exception.
    }
}
Daniel Minnaar
  • 5,865
  • 5
  • 31
  • 52
12

I was getting this issue intermittently, I had followed the instructions here and very similar ones elsewhere. All was configured correctly.

This page: http://sysadminwebsite.wordpress.com/2012/05/29/9/ helped me find the problem.

Basically I had duplicate CID's for the MSDTC across both servers. HKEY_CLASSES_ROOT\CID

See: http://msdn.microsoft.com/en-us/library/aa561924.aspx section Ensure that MSDTC is assigned a unique CID value

I am working with virtual servers and our server team likes to use the same image for every server. It's a simple fix and we didn't need a restart. But the DTC service did need setting to Automatic startup and did need to be started after the re-install.

Tod
  • 2,070
  • 21
  • 27
3

Comment from answer: "make sure you use the same open connection for all the database calls inside the transaction. – Magnus"

Our users are stored in a separate db from the data I was working with in the transactions. Opening the db connection to get the user was causing this error for me. Moving the other db connection and user lookup outside of the transaction scope fixed the error.

Toffman
  • 36
  • 1
  • 7
Bakanekobrain
  • 423
  • 6
  • 14
3

I was having this issue with a linked server in SSMS while trying to create a stored procedure.

On the linked server, I changed the server option "Enable Promotion on Distributed Transaction" to False.

Screenshot of Server Options

2

I post the below solution here because after some searching this is where I landed, so other may too. I was trying to use EF 6 to call a stored procedure, but had a similar error because the stored procedure had a linked server being utilized.

The operation could not be performed because OLE DB provider _ for linked server _ was unable to begin a distributed transaction

The partner transaction manager has disabled its support for remote/network transactions*

Jumping over to SQL Client did fix my issue, which also confirmed for me that it was an EF thing.

EF model generated method based attempt:

db.SomeStoredProcedure();

ExecuteSqlCommand based attempt:

db.Database.ExecuteSqlCommand("exec [SomeDB].[dbo].[SomeStoredProcedure]");

With:

var connectionString = db.Database.Connection.ConnectionString;
var connection = new System.Data.SqlClient.SqlConnection(connectionString);    
var cmd = connection.CreateCommand();
cmd.CommandText = "exec [SomeDB].[dbo].[SomeStoredProcedure]";

connection.Open();
var result = cmd.ExecuteNonQuery();

That code can be shortened, but I think that version is slightly more convenient for debugging and stepping through.

I don't believe that Sql Client is necessarily a preferred choice, but I felt this was at least worth sharing if anyone else having similar problems gets landed here by google.

The above Code is C#, but the concept of trying to switch over to Sql Client still applies. At the very least it will be diagnostic to attempt to do so.

Greg
  • 2,410
  • 21
  • 26
  • Interesting. I think you might want to edit the solution with VB code (there are code translators available), so it would match the tags of the question. However, I upvoted it nevertheless. – Lajos Arpad May 11 '18 at 08:31
2

If you could not find Local DTC in the component services try to run this PowerShell script first:

$DTCSettings = @(
"NetworkDtcAccess",               # Network DTC Access
"NetworkDtcAccessClients",        # Allow Remote Clients        ( Client and Administration)
"NetworkDtcAccessAdmin",          # Allow Remote Administration ( Client and Administration)
"NetworkDtcAccessTransactions",   #                (Transaction Manager Communication )
"NetworkDtcAccessInbound",        # Allow Inbound  (Transaction Manager Communication )
"NetworkDtcAccessOutbound" ,      # Allow Outbound (Transaction Manager Communication )
"XaTransactions",                 # Enable XA Transactions
"LuTransactions"                  # Enable SNA LU 6.2 Transactions
)
foreach($setting in $DTCSettings)
{
Set-ItemProperty -Path HKLM:\Software\Microsoft\MSDTC\Security -Name $setting -Value 1
} 
Restart-Service msdtc

And it appears!

Source: The partner transaction manager has disabled its support for remote/network transactions

Arthur Cam
  • 549
  • 6
  • 18
1

In case others have the same issue:

I had a similar error happening. turned out I was wrapping several SQL statements in a transactions, where one of them executed on a linked server (Merge statement in an EXEC(...) AT Server statement). I resolved the issue by opening a separate connection to the linked server, encapsulating that statement in a try...catch then abort the transaction on the original connection in case the catch is tripped.

aggaton
  • 3,066
  • 2
  • 25
  • 36
1

I had the same error message. For me changing pooling=False to ;pooling=true;Max Pool Size=200 in the connection string fixed the problem.

Aimery
  • 1,559
  • 1
  • 19
  • 24
Niels Bijl
  • 11
  • 1