同一个TransactionScope中不能操作两个及其以上的DATABASE

在使用LINQ TO SQL进行原子性操作时,遇到错误提示与DTC网络访问相关。实际上,问题源于在同一个TransactionScope内尝试操作两个不同的DATABASE。解决方法是将其中一个数据库的操作移出TransactionScope。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近用LINQ TO SQL,有些事情是需要原子性操作的,因此就用了一下事务,即TransactionScope。

但是在使用中发现如下的一个错误,查了很多资料才解决,在此分享一下:

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. InnerException: 
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)
   at 
System.Transactions.TransactionInterop.GetOletxTransactionFromTransmitterPropiga
tionTok

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值