Why is ThreadAbortException when trying to close SqlConnection in .NET?

I am making the following exception:

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 () raises the same exception. This seems to be normal in most places of my code, but only in this one function I cannot close the connection that I opened, because I keep getting ThreadAbortException. Am I at an impasse, any ideas? any clues? 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) 
+8
source share
1 answer

There was a terrible "Finalize" method that someone set. He continued to launch and try to close the connection. It was a couple of hours wasted! One day, I'm going to get rid of all the Finalize methods in the code - until then - suck it!

+1
source share

All Articles