Oracle.ManagedDataAccess.Client引发NullReferenceException

时间:2018-11-15 16:29:30

标签: c# oracle entity-framework

我正在使用带有Oracle.ManagedDataAccess的Entity Framework 6。偶尔会出现此错误:

System.NullReferenceException: Object reference not set to an instance of an object. at Oracle.ManagedDataAccess.Client.OracleConnection.get_m_majorVersion() at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteReader(Boolean requery, Boolean fillRequest, CommandBehavior behavior) at Oracle.ManagedDataAccess.Client.OracleCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed) at System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext) at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior) at System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues) at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess) at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass7.<GetResults>b__5() at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) at System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0() at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext() at System.Linq.Enumerable.First[TSource](IEnumerable`1 source) at MyApp.MyScheduler.AddSampleOperation(SampleOperation sampleOperation)

特别是在我打如下电话时发生:

_dbContext.SampleOperations.AsNoTracking().First(so => so.SampleOperationId == sampleOperation.SampleOperationId);

要清楚,这不是我控制的代码发生的NullReferenceException。它在Oracle客户端代码中发生,并且仅偶尔发生。我可以多次重现相同的步骤,并且不会发生错误,但最终会发生。我尝试从GAC删除Oracle.ManagedDataAccess.Client,但这没有帮助。

我希望其他人看到此错误。我正在使用NuGet的以下版本:

Oracle.ManagedDataAccess:12.1.24160719

Oracle.ManagedDataAccess.EntityFramework:12.1.2400

EntityFramework:6.1.3

是在更高版本的Oracle.ManagedDataAccess中修复的问题吗?

0 个答案:

没有答案