I have an OLE DB connection in VB.NET that I am trying to use to connect to an Oracle database. However, I get the following error on the con.Open() line:
LoaderLock was detected
Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.
Here is my code:
Dim con As New OleDb.OleDbConnection
ConfigConnection()
Try
con.ConnectionString = ConnectionString
Catch ex As Exception
MsgBox("Invalid connection string)
Return
End Try
Try
con.Open()
MsgBox("Connection attempt successfull!")
Catch ex As Exception
MsgBox("Unable to connect to data source.")
End Try
I use this same code to connect to various other types of databases, including SQL Server, Excel, and Access. When connecting to any of those it connects successfully and I don't get this error.
I am executing this code within a dll. If I execute it within an exe it works fine. However, I need to execute this within this dll.