You are currently offline, waiting for your internet to reconnect

FIX: Thread abort during SqlCommand.ExecuteReader corrupts SqlConnection pool

This article has been archived. It is offered "as is" and will no longer be updated.
If the following conditions are true:
  • A long running query that uses the SqlClient.SqlCommand.ExecuteReader method in a multithreaded .NET application is aborted.
  • Threads thereafter use the same connection string to try to read data by using SqlClient.SqlCommand.ExecuteReader.
you receive the following error message:
System.InvalidOperationException: There is already an open DataReader associated with this Connection which must be closed first.
The call stack may appear as follows:
at System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean executing)   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)   at System.Data.SqlClient.SqlCommand.ExecuteReader()					
When the thread that interacts with the DataReader object is aborted, the connection cannot be cleaned up properly because the SqlClient.SqlConnection.Close method that contains the cleanup code is not called. This leaves the connection in an indeterminate state and eventually causes the connection pool to enter an unusable state.
To resolve this problem, obtain the latest service pack for Microsoft .NET Framework. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
318836 How to obtain the latest .NET Framework service pack
The English version of this fix should have the following file attributes or later:
   Date            Version                                 Size              File name        --------------------------------------------------------------------   05-Mar-2002     1.0.3705.211    1,175,552 bytes   29-Jan-2002                                  1,831,936 bytes   NDP10U318609.msp				

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in Microsoft .NET Framework Service Pack 2 (SP2).
adonet connection pooling SQL Exception

Article ID: 319345 - Last Review: 06/19/2014 14:34:00 - Revision: 7.0

  • kbnosurvey kbarchive kbhotfixserver kbqfe kbbug kbfix kbnetframe100presp2fix kbnetframe100sp2fix KB319345