In .Net, is there any way to determine whether the ambient transaction is DTC transaction or not when debugging. I investigated SqlConnection class members but I found nothing. thanks.
views:
189answers:
2Set a breakpoint on the statement after the TransactionScope is instantiated, then execute the following command:
? System.Transactions.Transaction.Current
This will show you what type of Transaction you are enlisted in. If you are not in a DTC transaction, then you should see a System.Transactions.Ltm.LightweightTransaction
.
From this MSDN article: ADO.NET and System.Transactions which also discusses when transactions get promoted to DTC.
Of interest: How to determine whether SqlConnection is enlisted into a System.Transactions' tx or not?
I prefer to check the DistributedIdentifier Property.
In the immediate window while debugging type:
System.Transactions.Transaction.Current.TransactionInformation.DistributedIdentifier
If the value is Guid.Empty {00000000-0000-0000-0000-000000000000} then it is not a distributed transaction (the documentation says null but this is wrong since it is not a nullable type). Any other Guid value indicates that the transaction has been promoted to a distributed transaction.