none
Cannot access a disposed object. Object name: 'Transaction'. RRS feed

  • Question

  • Dear all,

    I am working in a client server application, (.net 2.0 )and in order to update tables in the DB I am using transactions like :

     

    using (TransactionScope scope = new TransactionScope())

    {

        .... do some work ....

     

        scope.Complete();

    }

     

    Sometime , when I try to complete the transaction,this error occurs :

     

    Cannot access a disposed object.

    Object name: ‘Transaction’.

     

    This is the stack:

     

    at System.Transactions.Transaction.get_IsolationLevel()

       at System.Data.SqlClient.SqlDelegatedTransaction..ctor(SqlInternalConnection connection, Transaction tx)

       at System.Data.SqlClient.SqlInternalConnection.EnlistNonNull(Transaction tx)

       at System.Data.SqlClient.SqlInternalConnection.Enlist(Transaction tx)

       at System.Data.SqlClient.SqlInternalConnectionTds.Activate(Transaction transaction)

       at System.Data.ProviderBase.DbConnectionInternal.ActivateConnection(Transaction transaction)

       at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)

       at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)

       at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)

       at System.Data.SqlClient.SqlConnection.Open()

     

    Many thanks

    Monday, December 6, 2010 10:24 AM

Answers