TransactionScope random error in debug mode
I get following error randomly when executing code from debug mode.
Cannot access a disposed object.
Objec开发者_JAVA技巧t name: 'SqlDelegatedTransaction'.
- Error is being thrown after few commands have been executed instantly, not an timeout issue
I have just one transaction, opened with
using(var scope = new TransactionScope(TransactionOption.Required))
Multiple connections are opened with same statement above in nested code.
i am using sqlserver 2008
What could be wrong?
When you use TransactionOption.Required the transaction joins the ambient transaction.
One possible theory is:
- If you go through the transaction scope and do not call scope.Complete(), it will dispose the abmient transaction. The next code that tries to run against the database will then fail.
Another would be problems with respect to active result sets:
- Are you using SQL Server 2000, which does not support Multiple Active Result Sets(MARS)
- Does your connect string specify MultipleActiveResultSets= true
精彩评论