I'm trying to use the following code to create a transaction.
Now, to test it the line
TManager.VehiclesTableAdapter.Adapter.Update(ChangedSet.Vehicles);
will always raise a NullReferenceException.
According to http://msdn2.microsoft.com/en-us/library/system.transactions.transactionscope.aspx the transaction should be rolled back as soon as an exception occurs within the transactionscope.
This doesn't happen and the transaction always suceeds.
It only works when I put the Ts.Complete within the try-statement (which kinda makes sense).
Am I misinterpreting something from the msdn-site?
"If no exception occurs within the transaction scope (that is, between the initialization of the TransactionScope object and the calling of its Dispose method), then the transaction in which the scope participates is allowed to proceed. If an exception does occur within the transaction scope, the transaction in which it participates will be rolled back."
I thought it automatically rolls back if an exception occurs.
So, if I'am wrong, what does the article actually mean?
Open in new window