views:

614

answers:

2

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?

+8  A: 

If you mean in relation to SQL Server, then there is an issue that you can fix in the connection string; see my reply here, or the full details here.

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.

Marc Gravell
Works like a charm. Thank you.
Keith Sirmons
+3  A: 

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.

Jared Moore