使用事务处理SQL数据时,遇到Exception:The transaction manager has disabled its support for remote/network transactions
2011-09-22 12:01
896 查看
本地是.net开发的Console Application, 利用Entity Framework 访问数据库,数据库在另一个Server机器上,使用SQL Server 2005。在本地调试代码,连接远程数据库,使用事务处理数据插入的问题时,遇到Exception。部分代码如下:
在执行第一次的SaveChanges时,没有问题,但在执行第二次的SaveChanges时,Catch到Exception。如图:
主要的错误是这里: {"The transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D024)"}
从网上查了一下,主要是因为网络在访问MSTDC时,有限制,默认是不允许通过网络访问的。解决办法如下:
确认"Distribute Transaction Coordinator"服务在Server和本地都是运行状态。
在Server上打开 Component Services。 Control Panel –> System and Security –> Administrative Tools –> Component Services.
展开至 Component Services –> Computers –> My Computer –> Distributed Transaction Coordinator –> Local DTC, 右键,选择Properties。在弹出的Dialog中选择Tab “Security”, 勾选Network DTC Access 等选项,具体设置如下图。
确认后会要求重新启动Service。注:如果在后面的步骤做完后,还是无法解决问题,可能需要重启电脑。
确认DTC不会被你的防火墙阻止。
重复以上2-5 在你本地(Client)也执行一遍。
再次运行程序,问题解决。如果还有问题,一是重启电脑,二是检查SQL Server中的DTC是否开启。
try { using (TransactionScope scope = new TransactionScope()) { this.dbEntites.ResultInfoes.AddObject(info); this.dbEntites.SaveChanges(); result.Id = info.Id; this.dbEntites.Results.AddObject(result); this.dbEntites.SaveChanges(); scope.Complete(); } } catch (Exception ex) { Trace.WriteLine("Cannot add result into database."); Trace.WriteLine(ex); }
在执行第一次的SaveChanges时,没有问题,但在执行第二次的SaveChanges时,Catch到Exception。如图:
主要的错误是这里: {"The transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D024)"}
从网上查了一下,主要是因为网络在访问MSTDC时,有限制,默认是不允许通过网络访问的。解决办法如下:
确认"Distribute Transaction Coordinator"服务在Server和本地都是运行状态。
在Server上打开 Component Services。 Control Panel –> System and Security –> Administrative Tools –> Component Services.
展开至 Component Services –> Computers –> My Computer –> Distributed Transaction Coordinator –> Local DTC, 右键,选择Properties。在弹出的Dialog中选择Tab “Security”, 勾选Network DTC Access 等选项,具体设置如下图。
确认后会要求重新启动Service。注:如果在后面的步骤做完后,还是无法解决问题,可能需要重启电脑。
确认DTC不会被你的防火墙阻止。
重复以上2-5 在你本地(Client)也执行一遍。
再次运行程序,问题解决。如果还有问题,一是重启电脑,二是检查SQL Server中的DTC是否开启。
相关文章推荐
- transaction manager has disabled its support for remote/network transactions. 该伙伴事务管理器已经禁止了它对远程/网络事务的支持
- The partner transaction manager has disabled its support for remote/network transactions
- transaction manager has disabled its support for remote/network transactions. 该伙伴事务管理器已经禁止了它对远程/网络事务
- transaction manager has disabled its support for remote/network transactions. 该伙伴事务管理器已经禁止了它对远程/网络事务
- The partner transaction manager has disabled its support for remote/network transactions.
- Network access for Distributed Transaction Manager (MSDTC) has been disabled (转载)
- 使用子事务(saveponit)时,当子事务抛出异常后,此异常处理掉不继续往外抛, Transaction has been rolled back because it has been marke
- SQL 2005 Tips --事务处理The current transaction cannot be committed and cannot support operations that write to the log file
- 使用Oracle SQL Developer连接数据库时,提示“执行请求的操作时遇到错误:IO 错误: The Network Adapter could not establish”,不知如何处理
- 部署K2 Blackpearl流程时出错(与基础事务管理器的通信失败或Communication with the underlying transaction manager has failed.
- 使用cocapods报错 [!] Your Podfile has had smart quotes sanitised. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes
- ssh开发中插入数据时遇到 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right
- PL/SQL编辑数据"这些查询结果不可更新,请包括ROWID或使用SELECT...FOR UPDATE获得可更新结果"处理
- 【转】PL/SQL编辑数据"这些查询结果不可更新,请包括ROWID或使用SELECT...FOR UPDATE获得可更新结果"处理
- 遇到WARNING:Could not lower the asynch I/O limit to 170 for SQL direct I/O. It is set to -1
- PL/SQL编辑数据"这些查询结果不可更新,请包括ROWID或使用SELECT...FOR UPDATE获得可更新结果"处理
- 部署K2 Blackpearl流程时出错(与基础事务管理器的通信失败或Communication with the underlying transaction manager has failed.)
- (转)PL/SQL编辑数据"这些查询结果不可更新,请包括ROWID或使用SELECT...FOR UPDATE获得可更新结果"处理
- 部署K2 Blackpearl流程时出错(与基础事务管理器的通信失败或Communication with the underlying transaction manager has failed.
- beego一个请求中的事务处理不能使用全局的orm实例,否则:transaction has started