How to: TransactionScope automatically escalating to MSDTC on some machines?
How to: TransactionScope automatically escalating to MSDTC on some machines?
TransactionScope automatically escalating to MSDTC on some machines?
In our project we’re using TransactionScope’s to ensure our data access layer performs it’s actions in a transaction. We’re aiming to not require the MSDTC service to be enabled on our end-user’s machines.
Trouble is, on half of our developers machines, we can run with MSDTC disabled. The other half must have it enabled or they…
遇到的第二個錯誤是 The operation is not valid for the state of the transaction. 錯誤發生在離開 tx2 後, 回到 tx1 後續的 DB 存取程式碼. 由於 tx2 現在的 transaction 跟 tx1 是共用的, 所以 tx2 執行完後, 如果沒有呼叫 Complete() 的話, 整個 transaction 的狀態會被視為有錯誤並且要 rollback 的. 我在 tx2 裡面, 把寫入 DB 的部分放在 if (needChange) 的判斷裡, 自以為能夠少做點不必要的事情, 沒想到 Complete() 變成一個必須要呼叫的事情. 稍微改寫後, 也就不會發生這個錯誤了.