0

I have a legacy Visual Studio (mainly VB, but some C# thrown in) web application that uses Oracle.DataAccess to access our data. Our production web server is 32-bit, so it has to use the 32-bit drivers, and I do have a 32-bit version of Oracle installed locally. I have two different versions of Oracle.DataAccess.dll, but neither works; each one throws a different error when the code calls (OracleConnection).Open(). One throws "Attempt to read or write protected memory"; the other throws a Null Reference Exception.

I can get it to work if I switch everything to the ManagedDataAccess driver, but that is not an option at production level.

What could be causing the two problems, and how can this be fixed without switching to ManagedDataAccess?

Update:

After looking at the comments, I have a feeling the problem is, the 32-bit DLL is trying to access my 64-bit Oracle installation rather than my 32-bit one. I have added the following to my web.config:

<configSections>
    <section name="oracle.dataaccess.client" type="OracleInternal.Common.CustomSectionHandler, Oracle.DataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</configSections>
<configuration>
    <oracle.dataaccess.client>
        <version number="*">
            <settings>
                <add name="DllPath" value="C:\Ora32\bin" />
            </settings>
        </version>
    </oracle.dataaccess.client>
</configuration>

but I still get the "Object instance not set to an instance of an object" error. Here is the stack trace:

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Oracle.DataAccess
  StackTrace:
   at Oracle.DataAccess.Client.OracleException.get_Number()
   at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure, Boolean bCheck, Int32 isRecoverable, OracleLogicalTransaction m_OracleLogicalTransaction)
   at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, Object src, OracleLogicalTransaction m_oracleLogicalTransaction)
   at Oracle.DataAccess.Client.OracleConnectionOCP.Open(OracleConnection con)
   at Oracle.DataAccess.Client.OracleConnection.Open()
   at {(OracleConnection variable).Open() call in my code}

I have a feeling it is ignoring the DLL Path setting in web.config, as when I change it to a directory that does not exist, I get the same error.

  • Have a look at this: https://stackoverflow.com/questions/659341/the-provider-is-not-compatible-with-the-version-of-oracle-client/25412992#25412992 – Wernfried Domscheit Jan 12 '22 at 18:45
  • 2
    Do you have installed also two Oracle clients installed? The version of Oracle.DataAccess.dll must match with the Oracle client and having more than one Oracle client installed is really painful. – Wernfried Domscheit Jan 12 '22 at 18:47

0 Answers0