C#,Linq2Sql,TransactionScope,“事务已中止”。,msdtc,sqlserver 2005 [英] C#, Linq2Sql, TransactionScope, "Transaction has aborted.", msdtc, sqlserver 2005

查看:309
本文介绍了C#,Linq2Sql,TransactionScope,“事务已中止”。,msdtc,sqlserver 2005的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在.NET 4项目中遇到TransactionScope问题。

we're having issues with TransactionScope in a .NET 4 project.

我们已经将DAL细分为多个域,也就是说,我们有不同的Linq2Sql DataContexts指向

We have segmented our DAL's into domains, that is we have different Linq2Sql DataContexts pointing to the same database.

当在同一个TransactionScope中,我们在多个DataContext上插入/更新时,立即会出现一个本地和本地的msdtc事务弹出的问题。服务器,然后将其挂在这里1-2分钟(猜测超时),然后代码将继续运行,直到t.Complete()和随后的隐含代码。Dispose将产生并且异常事务已中止。 。

The issue arises when, within the same TransactionScope, we insert/update on more than one DataContext, instantly a msdtc transaction will pop up, both locally and on the server, and then it will just hang there for 1-2 minutes (guess it times out), the code will then continue to run, until t.Complete() and subsequent implied .Dispose will yield and Exception "Transaction has aborted.".

我们已经在本地和服务器上都配置了msdtc,以允许所有,没有身份验证,完整的跟踪级别,但仍然没有来自dtctrace.log的相关信息

We have configured msdtc both locally and on the server to allow all, no authentication, full trace levels, still no relevant information comes from the dtctrace.log

我想这是启动多个数据库连接(即使是同一个数据库)时启动msdtc的标准过程,但是为什么会超时呢?操作没有冲突,在我们的域中没有可能发生死锁吗?

I guess it is standard procedure for msdtc to kick in when more that one database connection is initiated (even if it is vs. the same database), but why the timeout? The operations are not conflicting, there is no possible way for a deadlock to occur in our domain?

已经在Google上进行了广泛的搜索和测试,希望在这里有一些经验丰富的经验:)

Have googled and tested extensively, hope for some seasoned experience here :)

推荐答案

使用SQL2005,跨越多个连接的任何事务都将升级为DTC。使用SQL2008,具有相同连接字符串的多个连接可以参与同一事务,而无需DTC。如果您选择了这种架构,强烈建议您升级到SQL2008。 DTC可以使涂料正常工作。

With SQL2005 any transaction spanning multiple connections will be escalated to DTC. With SQL2008, several connections with the same connection string can participate in the same transaction without the need for DTC. With the architecture you've chosen I'd strongly suggest upgrading to SQL2008 if that is an option. DTC can be a paint to get working correctly.

这篇关于C#,Linq2Sql,TransactionScope,“事务已中止”。,msdtc,sqlserver 2005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆