Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I think the documentation on TransactionAbortedException is a little lacking as to when it can happen.

It DOES NOT happen if you do not do a Scope.Complete on your initial transaction. In other words, failure to execute Scope.Complete means that it will silently exit a transactionscope using block. (Since there is no other way to cancel the transactionscope silently, this is acceptable but should be documented clearly.)
If you need to alert your processes that you are aborting the initial transaction, you should do so by throwing an exception, which will silently close the transactionscope automatically. You may want to have a try/catch wrapping your transactionscope using block to catch these exceptions.

However, if have multiple same level calls to processes that have their own transactionscope using block that join the ambient transaction, you will get the exception if you fail to Scope.Complete on a call. When a subsequent call initiates the transactionscope, it sees a dirty transaction and will issue the transactionabortedexception at that point.
However, if you are nesting calls and the child call does not issue a scope.complete, then any other child call open above it will NOT issue an abort exception when it issues a scope.complete(), it will only be caught if another transaction is attempted or when the initial transasctionscope issues a scope.complete.
Posted
Comments
Sergey Alexandrovich Kryukov 27-May-11 11:43am    
Did I understand you right: this is not a question?
If it is not, you're off-topic. If this is what I think, please follow my advice you will find in my answer below.

Thank you.
--SA

As I understand, this is not a question.

What you right here looks important, so I would advice you write a short Tips/Trick article and post it by using this page: http://www.codeproject.com/Tips/post.aspx[^].

Thank you,
—SA
 
Share this answer
 
Are tips and questions both searched at the same time? If not, then anyone looking for transactionscope exception issues would want to find this in questions in my opinion.
Brian
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900