FIX: You receive the ObjectDisposedException exception when you refer to the Transaction.Current.TransactionInformation object

Article ID: 960754 – Last Review: January 23, 2009 – Revision: 1.0

FIX: You receive the ObjectDisposedException exception when you refer to the Transaction.Current.TransactionInformation object

SYMPTOMS

Consider the following scenario:

  • You install the .NET Framework 2.0 or a later version of the .NET Framework.
  • You have an application that connects to Microsoft SQL Server 2008 by using the .NET Framework Data Provider for SQL Server.
  • The application uses the TransactionScope object to start a transaction.
  • In the transaction, you open a connection and enable the connection pool, and then you close the connection.

    Note You can specify Pooling=true in the connection string to enable the connection pool. The default value is true.

After the connection is closed, a time-out or an exception occurs. If you reference to the Transaction.Current.TransactionInformation object, you may receive the following error message:

System.ObjectDisposedException: Cannot access a disposed object
……

CAUSE

The transaction rolls back because of the time-out or the exception. This causes the transaction object to be disposed of. When you try to access the current transaction information, this triggers the ObjectDisposedException exception.

WORKAROUND

To work around this problem, refer the transaction information from the TransactionEventArgs class in the Transaction Completed Event Handler.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the Applies to section.


APPLIES TO
  • Microsoft .NET Framework 2.0
  • Microsoft .NET Framework 3.5
Keywords: 
kbhotfixserver kbexpertiseadvanced kbqfe kbsurveynew KB960754

 

Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
Microsoft Corporation. All rights reserved. Terms of Use | Trademarks


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply

*
To prove that you're not a bot, enter this code
Anti-Spam Image