I have some code using a System.Transactions.TransactionScope
, that creating a new instance of the transaction scope simply halts the program.
There are no exceptions or messages, the program simply stops and Visual Studio returns to code editing mode. The process is completely gone. There are no exceptions, messages or events in the event viewer.
I have another test app that uses TransactionScope with no problem, so it shouldn't be an environment issue.
I just don't know how to get the exception detail. I've turned on all the "thrown" checkboxes in the Debug->Exceptions dialog within Visual Studio, hoping that VS would automatically break when the exception was thrown, but it doesn't.
Can anyone help me get the reason for the program exiting?
EDIT: I just found something new. The TransactionScope is being created in a method running on a background thread via ThreadPool.QueueUserWorkItem
. If I just call the method directly on the main application thread, this problem goes away. So now my question is "what is the problem with using TransactionScope on a threadpool thread?". Note I'm not starting a transaction scope before invoking the new thread, it's all within one method running on the threadpool thread.