在过去的几年中,我一直在使用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
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)
我的项目中具有以下与config 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>
答案 0 :(得分:2)
Proabaly 迟到的回复,但我遇到了同样的问题
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 文件夹