What is the reason of “Transaction context in use by another session”

前端 未结 6 568
孤独总比滥情好
孤独总比滥情好 2020-12-10 02:42

I\'m looking for a description of the root of this error: \"Transaction context in use by another session\".

I get it sometimes in one of my unittests so I can\'t pr

6条回答
  •  既然无缘
    2020-12-10 03:26

    Take a step back and focus more on your code and less in the multiple threads info floating around.

    If your scenario doesn't involve threading, it might relate to pieces that aren't closed as you expect it to.

    Maybe the sql code you are calling doesn't reach that commit transaction instruction. Or there is something else involved at that level. Maybe you used a SqlConnection instance setting the transaction in the .net code, and are reusing that same instance on the other code that uses the TransactionScope. Try adding using() instructions where appropriate, to make sure everything is closed as you expect it.

提交回复
热议问题