1

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.

StackoverflowPost1

and

StackoverflowPost2

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.

Community
  • 1
  • 1
MARKAND Bhatt
  • 2,428
  • 10
  • 47
  • 80
  • What is the state of the transaction? Did an exception occur somewhere else, and did this cause the transaction to abort? – Maarten Oct 17 '14 at 10:40
  • Yes, an exception occurs. But the innerText of the exception is null. Yes that causes the transaction to abort – MARKAND Bhatt Oct 18 '14 at 04:35
  • if an exception occurred in `UpdateDataBase1();` you won't be able to use the same transaction in `UpdateDataBase2();` you could check the state of the transaction before calling `UpdateDataBase2();` – 3dd Apr 17 '15 at 05:46

0 Answers0