Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Cannot access a disposed object. Object name: 'Transaction'.

$
0
0

Hi,

Over the last month or so despite no changes to the system, my users have sporadically started to receive the below error when using my asp.net web page:-

Upload of file failed - System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'Transaction'.
   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()

-----------

In my code I set up two connections:-

Connection conn = new Connection(new MSSQLDataSourceProvider(Server, Database, User, Password));
Connection conn2 = new Connection(new MSSQLDataSourceProvider(Server2, Database2, User2, Password2));

Then open TransactionScope and do some work to create my SQL and run some SQL with the first connection.

When trying to open the connection here I receive the above error.

This doesn't take long to do at all so I can't undertsand why we receive the above error and why it only happens rarely.

Any ideas anyone?

Thanks


Viewing all articles
Browse latest Browse all 31927

Trending Articles



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