I keep getting the following exception when I do:
Using cnn As SqlConnection = New SqlConnection(ConnectionStr)
cnn.Open() 'I am fine up to here'
End Using 'Here I am getting the following exception'
Manually called cnn.Dispose() causes the same exception. It seems to be OK in most places in my code but just in this one function I can't close the connection that I opened because I keep getting the ThreadAbortException. I am stumped, any ideas? any hints? Here is the exception I get:
System.TypeInitializationException: The type initializer for 'System.Data.ProviderBase.DbConnectionClosedPreviouslyOpened' threw an exception. ---> System.Threading.ThreadAbortException: Exception of type 'System.Threading.ThreadAbortException' was thrown.
--- End of inner exception stack trace ---
at System.Data.ProviderBase.DbConnectionInternal.CloseConnection(DbConnection owningObject, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlInternalConnection.CloseConnection(DbConnection owningObject, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Close()
at System.Data.SqlClient.SqlConnection.Dispose(Boolean disposing)
There was a dreaded "Finalize" method that someone put. It kept triggering and trying to close the connection. That was a couple of hours wasted!!! One day am going to get rid of all the Finalize methods in the code - until then - suck it up!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With