Oracle.ManagedDataAccess.Client throws NullReferenceException












1















I'm using Entity Framework 6 with Oracle.ManagedDataAccess. Sporadically I get this error:



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)



It happens specifically when I make a call like:



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



To be clear, this is not a NullReferenceException happening with code that I control. It's happening in the Oracle client code, and it only happens sporadically. I can reproduce the same steps multiple times and the error won't happen, then eventually it does. I tried removing Oracle.ManagedDataAccess.Client from the GAC, but that didn't help.



I'm hoping someone else has seen this error. I'm using the following versions from NuGet:



Oracle.ManagedDataAccess: 12.1.24160719



Oracle.ManagedDataAccess.EntityFramework: 12.1.2400



EntityFramework: 6.1.3



Could it be something that was fixed in a later version Oracle.ManagedDataAccess?










share|improve this question


















  • 1





    Version 12.1 was the first release of Oracle.ManagedDataAccess. I would give a try on newer version, i.e. 12.2

    – Wernfried Domscheit
    Nov 15 '18 at 17:18






  • 1





    You can now get the Oracle drivers from NuGet nuget.org/packages/Oracle.ManagedDataAccess , so try that. And also make sure that you're not accessing a DbContext instance from multiple threads, which can cause sporadic failures with any provider.

    – David Browne - Microsoft
    Nov 15 '18 at 17:20













  • I'm going to try upgrading to 12.2. @DavidBrowne-Microsoft question - if all access to the DbContext is always wrapped in a lock, would that prevent the sporadic failures?

    – Jeff F.
    Nov 15 '18 at 19:47











  • Yes. The DbContext can be accessed from different threads, just not at the same time. Although for performance you normally would not do that.

    – David Browne - Microsoft
    Nov 15 '18 at 20:12






  • 1





    I found a place where the db context was being accessed potentially from a separate thread without a lock. That might actually be the underlying cause of this. You might want to search your code for that.

    – Jeff F.
    Nov 30 '18 at 19:57
















1















I'm using Entity Framework 6 with Oracle.ManagedDataAccess. Sporadically I get this error:



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)



It happens specifically when I make a call like:



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



To be clear, this is not a NullReferenceException happening with code that I control. It's happening in the Oracle client code, and it only happens sporadically. I can reproduce the same steps multiple times and the error won't happen, then eventually it does. I tried removing Oracle.ManagedDataAccess.Client from the GAC, but that didn't help.



I'm hoping someone else has seen this error. I'm using the following versions from NuGet:



Oracle.ManagedDataAccess: 12.1.24160719



Oracle.ManagedDataAccess.EntityFramework: 12.1.2400



EntityFramework: 6.1.3



Could it be something that was fixed in a later version Oracle.ManagedDataAccess?










share|improve this question


















  • 1





    Version 12.1 was the first release of Oracle.ManagedDataAccess. I would give a try on newer version, i.e. 12.2

    – Wernfried Domscheit
    Nov 15 '18 at 17:18






  • 1





    You can now get the Oracle drivers from NuGet nuget.org/packages/Oracle.ManagedDataAccess , so try that. And also make sure that you're not accessing a DbContext instance from multiple threads, which can cause sporadic failures with any provider.

    – David Browne - Microsoft
    Nov 15 '18 at 17:20













  • I'm going to try upgrading to 12.2. @DavidBrowne-Microsoft question - if all access to the DbContext is always wrapped in a lock, would that prevent the sporadic failures?

    – Jeff F.
    Nov 15 '18 at 19:47











  • Yes. The DbContext can be accessed from different threads, just not at the same time. Although for performance you normally would not do that.

    – David Browne - Microsoft
    Nov 15 '18 at 20:12






  • 1





    I found a place where the db context was being accessed potentially from a separate thread without a lock. That might actually be the underlying cause of this. You might want to search your code for that.

    – Jeff F.
    Nov 30 '18 at 19:57














1












1








1








I'm using Entity Framework 6 with Oracle.ManagedDataAccess. Sporadically I get this error:



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)



It happens specifically when I make a call like:



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



To be clear, this is not a NullReferenceException happening with code that I control. It's happening in the Oracle client code, and it only happens sporadically. I can reproduce the same steps multiple times and the error won't happen, then eventually it does. I tried removing Oracle.ManagedDataAccess.Client from the GAC, but that didn't help.



I'm hoping someone else has seen this error. I'm using the following versions from NuGet:



Oracle.ManagedDataAccess: 12.1.24160719



Oracle.ManagedDataAccess.EntityFramework: 12.1.2400



EntityFramework: 6.1.3



Could it be something that was fixed in a later version Oracle.ManagedDataAccess?










share|improve this question














I'm using Entity Framework 6 with Oracle.ManagedDataAccess. Sporadically I get this error:



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)



It happens specifically when I make a call like:



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



To be clear, this is not a NullReferenceException happening with code that I control. It's happening in the Oracle client code, and it only happens sporadically. I can reproduce the same steps multiple times and the error won't happen, then eventually it does. I tried removing Oracle.ManagedDataAccess.Client from the GAC, but that didn't help.



I'm hoping someone else has seen this error. I'm using the following versions from NuGet:



Oracle.ManagedDataAccess: 12.1.24160719



Oracle.ManagedDataAccess.EntityFramework: 12.1.2400



EntityFramework: 6.1.3



Could it be something that was fixed in a later version Oracle.ManagedDataAccess?







c# oracle entity-framework






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 16:29









Jeff F.Jeff F.

81449




81449








  • 1





    Version 12.1 was the first release of Oracle.ManagedDataAccess. I would give a try on newer version, i.e. 12.2

    – Wernfried Domscheit
    Nov 15 '18 at 17:18






  • 1





    You can now get the Oracle drivers from NuGet nuget.org/packages/Oracle.ManagedDataAccess , so try that. And also make sure that you're not accessing a DbContext instance from multiple threads, which can cause sporadic failures with any provider.

    – David Browne - Microsoft
    Nov 15 '18 at 17:20













  • I'm going to try upgrading to 12.2. @DavidBrowne-Microsoft question - if all access to the DbContext is always wrapped in a lock, would that prevent the sporadic failures?

    – Jeff F.
    Nov 15 '18 at 19:47











  • Yes. The DbContext can be accessed from different threads, just not at the same time. Although for performance you normally would not do that.

    – David Browne - Microsoft
    Nov 15 '18 at 20:12






  • 1





    I found a place where the db context was being accessed potentially from a separate thread without a lock. That might actually be the underlying cause of this. You might want to search your code for that.

    – Jeff F.
    Nov 30 '18 at 19:57














  • 1





    Version 12.1 was the first release of Oracle.ManagedDataAccess. I would give a try on newer version, i.e. 12.2

    – Wernfried Domscheit
    Nov 15 '18 at 17:18






  • 1





    You can now get the Oracle drivers from NuGet nuget.org/packages/Oracle.ManagedDataAccess , so try that. And also make sure that you're not accessing a DbContext instance from multiple threads, which can cause sporadic failures with any provider.

    – David Browne - Microsoft
    Nov 15 '18 at 17:20













  • I'm going to try upgrading to 12.2. @DavidBrowne-Microsoft question - if all access to the DbContext is always wrapped in a lock, would that prevent the sporadic failures?

    – Jeff F.
    Nov 15 '18 at 19:47











  • Yes. The DbContext can be accessed from different threads, just not at the same time. Although for performance you normally would not do that.

    – David Browne - Microsoft
    Nov 15 '18 at 20:12






  • 1





    I found a place where the db context was being accessed potentially from a separate thread without a lock. That might actually be the underlying cause of this. You might want to search your code for that.

    – Jeff F.
    Nov 30 '18 at 19:57








1




1





Version 12.1 was the first release of Oracle.ManagedDataAccess. I would give a try on newer version, i.e. 12.2

– Wernfried Domscheit
Nov 15 '18 at 17:18





Version 12.1 was the first release of Oracle.ManagedDataAccess. I would give a try on newer version, i.e. 12.2

– Wernfried Domscheit
Nov 15 '18 at 17:18




1




1





You can now get the Oracle drivers from NuGet nuget.org/packages/Oracle.ManagedDataAccess , so try that. And also make sure that you're not accessing a DbContext instance from multiple threads, which can cause sporadic failures with any provider.

– David Browne - Microsoft
Nov 15 '18 at 17:20







You can now get the Oracle drivers from NuGet nuget.org/packages/Oracle.ManagedDataAccess , so try that. And also make sure that you're not accessing a DbContext instance from multiple threads, which can cause sporadic failures with any provider.

– David Browne - Microsoft
Nov 15 '18 at 17:20















I'm going to try upgrading to 12.2. @DavidBrowne-Microsoft question - if all access to the DbContext is always wrapped in a lock, would that prevent the sporadic failures?

– Jeff F.
Nov 15 '18 at 19:47





I'm going to try upgrading to 12.2. @DavidBrowne-Microsoft question - if all access to the DbContext is always wrapped in a lock, would that prevent the sporadic failures?

– Jeff F.
Nov 15 '18 at 19:47













Yes. The DbContext can be accessed from different threads, just not at the same time. Although for performance you normally would not do that.

– David Browne - Microsoft
Nov 15 '18 at 20:12





Yes. The DbContext can be accessed from different threads, just not at the same time. Although for performance you normally would not do that.

– David Browne - Microsoft
Nov 15 '18 at 20:12




1




1





I found a place where the db context was being accessed potentially from a separate thread without a lock. That might actually be the underlying cause of this. You might want to search your code for that.

– Jeff F.
Nov 30 '18 at 19:57





I found a place where the db context was being accessed potentially from a separate thread without a lock. That might actually be the underlying cause of this. You might want to search your code for that.

– Jeff F.
Nov 30 '18 at 19:57












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323888%2foracle-manageddataaccess-client-throws-nullreferenceexception%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323888%2foracle-manageddataaccess-client-throws-nullreferenceexception%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Retrieve a Users Dashboard in Tumblr with R and TumblR. Oauth Issues