When Commit is called (for the implementation of IEnlistmentNotification) can I just throw an exception to indicate I want the transaction to rollback?
A:
You should instead call Transaction.Rollback(Exception ex):
public void Commit(Enlistment enlistment)
{
Transaction currentTx = Transaction.Current;
if (currentTx != null)
{
currentTx.RollBack(new Exception("I give up!");
}
}
Mike Atlas
2010-06-07 22:17:27