TransactionScope bug in .NET? More information?
I have read (or perhaps heard from a colleague) that in .NET, TransactionScope can hit its timeout and then VoteCommit (as opposed to VoteRollback). Is this accurate or hearsay? I couldn't track down information on the web that talked about this issue (if it IS an issue), so I wonder if anyone has any direct experience with it and can shed some light?
The short version is: ensure you have
Transaction Binding=Explicit Unbind; in the connection string.
It isn't actually doing a vote commit - the transaction (and any early operations) has rolled back, but any subsequent operations (still inside the
TransactionScope) can get performed in the nul-transaction, i.e. auto-commit.
Risposta num. 1
The behaviour that Marc Gravell described has been changed in .Net 4.0. Instead of the operation being autocommitted, it will now throw an InvalidOperationException. So in 4.0 you no longer need to use Explicit Unbind.