ODP.Net Unmanged x64 导致未处理的异常

ODP.Net Unmanged x64 causes unhandled exception

在过去的几年里,我一直在使用 Oracle 的非托管驱动程序,即 2015 年 10 月以来的 32 位 Version=4.121.2.0

现在我正在尝试升级以使用新的 Oracle 客户端并使用 64 位 Version=4.122.18.3 当我尝试连接到数据库时,我收到一个错误,该错误似乎未在 Oracle 程序集内部处理,这使得很难确定问题所在。

然后我尝试将以前的版本 Version=4.122.1.0 与 x64 一起使用,但我也遇到了同样的错误。

任何想法如何使它工作或确定问题是什么将不胜感激。

错误:Object reference not set to an instance of an object

堆栈跟踪:

   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)

我的项目中有以下与 Oracle 相关的配置设置:

<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>

可能回复晚了,但我遇到了同样的问题

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

并由 :

修复

正在将 oraons.dll 从 oracle_home 复制到 oracle_home\bin 文件夹

例如 来自

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

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

如果您同时安装了 oracle 客户端和 ODAC,则从 ODAC 主目录复制到 ODAC\bin 文件夹