Search code examples
.netoracleodp.netodac

ODP.Net Unmanged x64 causes unhandled exception


for the past few years I have been using the Unmanaged driver for Oracle, the 32bit Version=4.121.2.0 from October 2015

Now I am trying to upgrade to use the new Oracle client and use the 64bit Version=4.122.18.3 When I try to connect to the database I get an error that seems to not be handled inside the Oracle assembly, and this makes it very hard to determine what the problem is.

I then tried to use the previous version instead Version=4.122.1.0 with x64 and I also get the same Error.

Any Ideas how to get this working or determine what the problem is will be much appreciated.

Error: Object reference not set to an instance of an object

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 Oracle.DataAccess.EntityFramework.EFOracleProviderServices.GetDbProviderManifestToken(DbConnection connection)
   at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)
   at System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest)
   at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
   at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
   at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   at System.Data.Entity.Internal.InternalContext.ExecuteSqlCommand(TransactionalBehavior transactionalBehavior, String sql, Object[] parameters)

I have the following config oracle related config setup in my project:

<system.data>
    <DbProviderFactories>
      <add name="ODP.NET, Unmanaged Driver" invariant="Oracle.DataAccess.Client" description="Oracle Data Provider for .NET, Unmanaged Driver" type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=4.122.18.3, Culture=neutral, PublicKeyToken=89b483f429c47342" />
    </DbProviderFactories>
  </system.data>
<entityFramework codeConfigurationType="ProFemOnline.Data.Old.ProFemDbModelOldConfiguration, ProFemOnline.Data.Old">
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
      <provider invariantName="Oracle.DataAccess.Client" type="Oracle.DataAccess.EntityFramework.EFOracleProviderServices, Oracle.DataAccess.EntityFramework, Version=6.122.18.3, Culture=neutral, PublicKeyToken=89b483f429c47342" />
    </providers>
  </entityFramework>

Solution

  • Proabaly a late reply, but I got same issue

    at Oracle.DataAccess.Client.OracleException.get_Number()
    

    and fixed by :

    copying the oraons.dll from oracle_home to oracle_home\bin folder

    e.g. from

    "C:\oracle\odac\oraons.dll"
    

    to

    "C:\oracle\odac\bin\oraons.dll"
    

    if you have both oracle client and ODAC installed then copy from ODAC home to ODAC\bin folder