Safe handle->ObjectDisposedException & SqlTransaction.Dispose - by Egor Sinkevich

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 779588 Comments
Status Closed Workarounds
Type Bug Repros 2
Opened 2/20/2013 2:52:35 AM
Access Restriction Public


Hi Guys!

We have server farm and recently have got really strange errors almost in the same time on the different servers in the farm. What we've got is ObjectDisposedException on the call to the SqlTransaction.Dispose. After several days of investigating we think that this is .NEt bug but caused by Sql Server. We didn't manage to reproduce the problem and only have a call stack. But even from the call stack it is obivious that this is bug.
Please have a look.

System.ObjectDisposedException: Safe handle has been closed
   at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
   at SNINativeMethodWrapper.SNIReadSync(SafeHandle pConn, IntPtr& packet, Int32 timeout)
   at System.Data.SqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult, TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParserStateObject.ReadNetworkPacket()
   at System.Data.SqlClient.TdsParserStateObject.ReadBuffer()
   at System.Data.SqlClient.TdsParserStateObject.CleanWire()
   at System.Data.SqlClient.SqlInternalConnectionTds.ValidateConnectionForExecute(SqlCommand command)
   at System.Data.SqlClient.SqlInternalTransaction.Rollback()
   at System.Data.SqlClient.SqlInternalTransaction.Dispose(Boolean disposing)
   at System.Data.SqlClient.SqlTransaction.Dispose(Boolean disposing)
   .... <our code> ...

Dispose method was called just once and from the finally block.
At the same time we had several timeouts on the SQL server and probably most important thing that at the same time we had timeout on the database file autogrow operation.

So, IMHO there are 2 problems:
1. Exception should never be throws from the Dispose
2. Something that caused this problem

Same/similar problem
Sign in to post a comment.
Posted by Young [MSFT] on 4/10/2013 at 9:36 PM
Hi Egor,

Thanks for reporting this issue. This will be fixed in a future release of .Net Framework. Please let us know if you have further questions.


Young Gah Kim
Development Lead
ADO.NET and DataSet Team
Posted by Macy [MSFT] on 2/21/2013 at 10:26 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Helen [MSFT] on 2/21/2013 at 1:51 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(