Error IM003 when connecting to Oracle ODBC data source in ASP.NET Core app on .NET Core 3.1 in IIS

0

I have an ASP.NET Core application running on .NET Core 3.1 in IIS 10 on Windows Server 2019. When trying to connect to an Oracle ODBC data source, I'm getting this error:

System.Data.Odbc.OdbcException (0x80131937): ERROR [IM003] Specified driver could not be loaded due to system error 1114: A dynamic link library (DLL) initialization routine failed. (Oracle in instantclient_12_2, C:\Oracle64\instantclient_12_2\SQORA32.dll).

at System.Data.Odbc.OdbcConnection.HandleError(...)
at System.Data.Odbc.OdbcConnectionHandle..ctor(...)
at System.Data.Odbc.OdbcConnectionOpen..ctor(...)
at System.Data.Odbc.OdbcConnectionFactory.CreateConnection(...)
at System.Data.ProviderBase.DbConnectionFactory.CreateConnection(...)
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(...) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(...) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(...) at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(...) at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(...) at System.Data.Odbc.OdbcConnection.Open()

On the server, I have the 64-bit Oracle ODBC driver (v12.2) installed, my DSN/connection is configured in the ODBC Data Sources (64-bit), and the Platform target for the ASP.NET Core app is "x64". My code boils down to this (with Dsn and Pwd sanitized):

        using (var odbcConnection = new OdbcConnection("Dsn=PROD_US_64;Pwd=abcdefg"))
        {
            odbcConnection.Open();
        }
        

And here's the crazy part. The exact same code works fine on that machine (and I am able to run queries and read data) as a ...

  • .NET Core 3.1 console application
  • .NET Framework 4.7.2 console application
  • ASP.NET MVC application targeting .NET Framework 4.7.2, in IIS.

This suggests that the problem seems to be something specific to ASP.NET Core.

I believe my ODBC driver is installed and configured correctly, and I don't believe this is a bitness (32 vs 64) problem. When I have a bitness mismatch, I get a different error ("OdbcException: ERROR [IM014] [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application").

I've tried:

  • Changing the IIS application pool to run under a different user account that has full Admin access.
  • Changing the "Enable 32-bit Application" setting in the IIS application pool to both 'True' and 'False'
  • Building my app for "Any CPU" as well as "x86" and "x64"

Any other ideas at all? I've been at this for a full day now and am willing to try anything.

oracle
iis
.net-core
odbc
asp.net-core-3.1
asked on Stack Overflow Jan 14, 2021 by Rajeev Goel

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0