HRESULT:0x8004D00E使用的TransactionScope - C#HRESULT、x8004D00E、TransactionScope

2023-09-05 02:49:32 作者:人间唯你值得

我收到以下错误,当我试图运行Windows Server 2003标准版SP1机器连接到SQL Server 2000上的一个C#WinForms应用程序,将数据的WinForms应用程序和插入转换成SQL服务器2005年应用程序。我连接到每一个数据库使用SSPI。

I received the following error when I tried to run a C# WinForms application on a Windows Server 2003 Standard Edition SP1 machine that was connecting to a SQL server 2000, converting the data in the WinForms app and inserting the converted into a SQL server 2005 application. I am connecting to each database using SSPI.

在code载一个TransactionScope块中:

The code was contained within a TransactionScope block:

System.TimeSpan TransactionTimeOut = new TimeSpan(0, 40, 0);

    using(TransactionScope Scope = new TransactionScope(TransactionScopeOption.RequiresNew, TransactionTimeOut))
    {
        try
        {
            //meat of transaction...
        }
        catch(Exception ex)
        {
            throw ex;
        }

        Scope.Complete();
    }

错误信息:

例外:本次交易已经有   一直或明或暗地   提交或中止。

Exception: The transaction has already been implicitly or explicitly committed or aborted.

内部异常:本次交易有   已经或明或暗地   从提交或中止(异常   HRESULT:0x8004D00E)

Inner Exception: The transaction has already been implicitly or explicitly committed or aborted (Exception from HRESULT: 0x8004D00E)

任何人知道什么可能会造成这个问题?

Any one know what might be causing this issue?

推荐答案

检查DTC已启动,你的code运行的机器上。由于使用的是2个连接在TransactionScope的,该交易将晋升为DTC基于事务。

Check that the DTC is started on the machine where your code is running. Since you are using 2 connections in the transactionscope, the transaction will be promoted to a DTC based transaction.

此外,检查安全性是否正确配置(通过允许DTC事务匿名参与检查这一点),并且您的防火墙通过它允许DTC。

Also, check that the security is configured correctly (check this by allowing anonymous participation in the DTC transaction), and that your firewall is allowing the DTC through it.

看看这个论坛,常见问题解答:分布式事务处理协调器(MSDTC)和交易常见问题解答

Check out this forum FAQ: Distributed Transaction Coordinator(MSDTC) and Transaction FAQ

[与此相关的SO问题:分布式事务处理协调器]

[Related to this SO question: Distributed Transaction Coordinator]