.Net嵌套事务范围错误 - MSDTC事务管理器无法提取事务 [英] .Net Nested Transaction Scope Error - The MSDTC transaction manager was unable to pull the transaction

查看:166
本文介绍了.Net嵌套事务范围错误 - MSDTC事务管理器无法提取事务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在单个事务范围内运行多个事务时抛出以下错误



错误 - MSDTC事务管理器无法从源事务管理器中提取事务由于通信问题。可能的原因是:存在防火墙并且它没有MSDTC进程的例外,两台机器无法通过其NetBIOS名称找到对方,或者没有启用对其中一个的网络事务的支持两个事务管理器。(HRESULT异常:0x8004D02B)



我使用下面的示例代码来保存卡片详细信息,

The below error is throwing while running multiple transaction in single transaction scope

Error - "The MSDTC transaction manager was unable to pull the transaction from the source transaction manager due to communication problems. Possible causes are: a firewall is present and it doesn't have an exception for the MSDTC process, the two machines cannot find each other by their NetBIOS names, or the support for network transactions is not enabled for one of the two transaction managers. (Exception from HRESULT: 0x8004D02B)"

I am using the below sample code to Save the Card details,

public Int64 SaveDetails(CardDO _Card)
{
    try
    {
        Int64 PayerId = 0;
        // Begin the transcation and call the add method
        var transactionScopeOptions = new TransactionOptions();
        transactionScopeOptions.IsolationLevel = System.Transactions.IsolationLevel.Serializable;
        transactionScopeOptions.Timeout = TimeSpan.MaxValue;
        using (TransactionScope OuterScope = new TransactionScope(TransactionScopeOption.Required, transactionScopeOptions))
        {
            using (TransactionScope InnerScope1 = new TransactionScope())
            {
                PayerId = SavePayer(_Card.PayerDetails, _Card.ROW_STATE);
                InnerScope1.Complete();
            }
            _Card.PAYER_ID = PayerId;
            using (TransactionScope InnerScope2 = new TransactionScope())
            {
                _Card.PAYER_ID = PayerId;
                if (_Card.ROW_STATE == RowState.Created)
                {
                    _Card._CARD_ID = SaveCardDetails(_Card);
                }
                else if (_Card.ROW_STATE == RowState.Modified)
                {
                    int result = UpdateCardDetails(_Card);
                    if (result <= 0)
                    {
                        throw new Exception("Error :  card updation failed.");
                    }
                }
                InnerScope2.Complete();
            }
            using (TransactionScope InnerScope3 = new TransactionScope())
            {
                SaveCardLabour(_Card.CardLabourList, _Card.ROW_STATE, _Card._CARD_ID);
                InnerScope3.Complete();
            }
            OuterScope.Complete();
        }
        // DALHelper.Instance.Commit(); // Commit the Transcation
        return _Card._CARD_ID;
    }
    catch (TransactionAbortedException ex)
    {
        throw new Exception(" Card Save Aborted: " + ex.Message);
    }
    catch (Exception ex)
    {
        throw ex;
    }
}





第一个数据库调用SavePayer()工作正常;当它进入第二个DB调用SaveCardDetails时,传输失败并得到以下错误,



MSDTC事务管理器无法从源中提取事务交易经理因沟通问题。可能的原因是:存在防火墙且MSDTC进程没有例外,两台计算机无法通过其NetBIOS名称找到对方,或者两个事务管理器之一未启用对网络事务的支持。 (HRESULT异常:0x8004D02B)



如果您对此问题有任何疑问,请帮帮我..



The first DB call "SavePayer()" is working perfect; when it enter the Second DB call "SaveCardDetails", transcation getting failed and am getting the below error,

The MSDTC transaction manager was unable to pull the transaction from the source transaction manager due to communication problems. Possible causes are: a firewall is present and it doesn't have an exception for the MSDTC process, the two machines cannot find each other by their NetBIOS names, or the support for network transactions is not enabled for one of the two transaction managers. (Exception from HRESULT: 0x8004D02B)

If you have any idea on this issue, help me out..

推荐答案



在您使用该事务的SavePlayer功能中。我认为交易可能会获得主要交易的参考。

或其他一个条件,当你可以面对问题时

当你放置嵌套事务时,它实际上会锁定表。

如果上面的transactino被锁定在表上,并且在打开另一个事务以使用该资源之后你就会遇到这个问题。

您粘贴的代码非常少。所以不知道你的保存更改是做什么的。

但是通常不会重新使用嵌套事务。

可能是这个指针可以帮你解决这个问题
Hi,
in the SavePlayer funtion you have used the transaction. I think it might be possible that the transaction might be getting reference of the main transaction.
or one other condtion when you can face the problem
When you put nested transaction it will actually put a lock on the table.
in case the upper transactino is put lock on the table and after you open another transaction to use that resource you can get this problem.
the code you have pasted is very less. so don't know what your save changes is doing.
but genrally it is not recomanded to use nested transactions.
may be this pointers can help you to solve this problem


这篇关于.Net嵌套事务范围错误 - MSDTC事务管理器无法提取事务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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