Oracle.DataAccess.dll (Oracle Data Provider for .NET, Unmanaged Driver), calling
Oracle.DataAccess.Client.OracleConnection.Open() method, you may encounter an
Oracle.DataAccess.Client.OracleException if you misconfigured your environment.
Oracle.DataAccess.Client.OracleException was unhandled by user code ErrorCode=-2147467259 HResult=-2147467259 Message="" StackTrace: at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck, Int32 isRecoverable) at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src) at Oracle.DataAccess.Client.OracleConnection.Open() at <... some user code ...>
Oracle.DataAccess.Client.OracleException is threw with its
Message set to an empty string, it means
Oracle.DataAccess.dll fails to load its dependent DLLs.
ODP.NET and Dependent Unmanaged DLL Mismatch
To enforce the usage of
Oracle.DataAccess.dllassembly with the correct version of its unmanaged DLLs, an exception is raised if
Oracle.DataAccess.dllnotices it has loaded a mismatched version of a dependent unmanaged DLL.
Though the documentation says an exception will be raised if a mismatched version of a dependent DLL is loaded, it actually includes the case that any of the dependent DLLs is not loaded.
This will happen if ODP.NET or Oracle Client is not installed, or dependent ODP.NET or Oracle DLLs are not placed at the side of the DLL running the code.
In addition, this will also happen if you have misconfigured your environment variable
ORACLE_HOME, setting it to an incorrect or invalid directory.
ORACLE_HOME is not required any more since 11g on Windows as its value can be inferred from registry key and values under
HKLM\SOFTWARE\ORACLE, and it prevents proper use of Multiple Oracle Homes. But if you do set this environment variable, it's okay as long as you set it correctly. Otherwise, you are going to face difficulties when using ODP.NET or other Oracle components.