I implemented Transaction Scope in my application. But i receive following error The operation is not valid for the state of the transaction. Here is my code
try{
using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
{
UpdateDataBase1();
UpdateDataBase2(); // this line throws error.
scope.Complete();
}
}
catch(Exception ex)
{
throw ex;//Inner exception is null
}
Both Databases are on same server(Server1)(MSDTC service is running).
My Application is on different server(server2).
I googled around and found two post with the same problem.
and
I found that there may be 2 main causes for my problem (1) MSDTC service and (2) Transacation Scope cannot handle to open connections.
But when i test the same scenario in local it works. The above 2 possible causes work very fine.I dont know what happens when i host them.
help me.