当我这样做时,我不断收到以下异常:
Using cnn As SqlConnection = New SqlConnection(ConnectionStr)
cnn.Open() 'I am fine up to here'
End Using 'Here I am getting the following exception'
手动调用 cnn.Dispose() 会导致相同的异常。在我的代码中的大多数地方似乎都可以,但就在这个函数中,我无法关闭我打开的连接,因为我不断收到 ThreadAbortException。我被难住了,有什么想法吗?任何提示?这是我得到的例外:
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)