vb.net 合作伙伴事务管理器已禁用对远程/网络事务的支持
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19365005/
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
The partner transaction manager has disabled its support for remote/network transactions
提问by w0051977
I have some code which is doing something like this (please note that the actual code is much more complex). I have produced this to aid explanation:
我有一些代码正在做这样的事情(请注意实际代码要复杂得多)。我制作了这个来帮助解释:
Imports System.Data.SqlClient
Imports System.Transactions
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Using scope As New TransactionScope
Try
Dim objCon As SqlConnection = New SqlConnection("Connection string 1")
Dim objCon2 As SqlConnection = New SqlConnection("Connection string 2")
objCon2.Open()
Using objCon2
Dim t1 As New Test
t1.Test()
objCon.Open()
End Using
Catch ex As Exception
'I do not swallow exceptions
End Try
End Using
End Sub
End Class
Public Class Test
Public Sub Test()
Dim objCon1 As SqlConnection = New SqlConnection("Connection string 1")
objCon1.Open()
End Sub
End Class
The code above shows that I am connecting to two databases inside the transaction (one of them is connected to twice). Here is the exception: FormLoad error: System.Transactions.TransactionException: The partner transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D025).
上面的代码显示我连接到事务内的两个数据库(其中一个连接到两次)。这是异常: FormLoad 错误:System.Transactions.TransactionException:合作伙伴事务管理器已禁用其对远程/网络事务的支持。(来自 HRESULT 的异常:0x8004D025)。
回答by Steve
See this SO post. The guy finds the answer to his question, and so much more.
请参阅此 SO 帖子。这家伙找到了他问题的答案,还有更多。
transactionscope-with-multiple-database-connections
Definately a good read if working with TransactionScope.
如果使用 TransactionScope,绝对是一本好书。

