Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

The operation is not valid for the state of the transaction.

$
0
0

I implemented Transaction Scope in my application. But i receive following errorThe 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 works very fine.I dont know what happens when i host them.

help me.


markand


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>