question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Object reference not set to an instance of an object (Entity History)

See original GitHub issue

Abp package version.: 3.4.0 base framework: .Net Framework Exception:

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Microsoft.AspNetCore.Http.Extensions
  StackTrace:
   at Microsoft.AspNetCore.Http.Extensions.UriHelper.GetDisplayUrl(HttpRequest request)
   at Abp.AspNetCore.EntityHistory.HttpRequestEntityChangeSetReasonProvider.get_Reason()
   at Abp.EntityHistory.EntityHistoryHelper.CreateEntityChangeSet(ICollection`1 entityEntries)
   at Abp.Zero.EntityFrameworkCore.AbpZeroCommonDbContext`3.<SaveChangesAsync>d__98.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.<SaveChangesInDbContextAsync>d__20.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.<SaveChangesAsync>d__12.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.<CompleteUowAsync>d__14.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.Domain.Uow.UnitOfWorkBase.<CompleteAsync>d__57.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.Domain.Uow.UnitOfWorkInterceptor.<>c__DisplayClass6_0.<<PerformAsyncUow>b__2>d.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Abp.Threading.InternalAsyncHelper.<AwaitTaskWithPostActionAndFinallyAndGetResult>d__5`1.MoveNext()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at SystemX.X.Reports.DetailedBankSalaryTransferReport.<>c__DisplayClass8_0.<<DetailedBankSalaryTransferReport_NeedDataSource>b__0>d.MoveNext() in D:\Work\src\SystemX System\src\X\SystemX.X.Reports\DetailedBankSalaryTransferReport.cs:line 44
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException[TResult](Task`1 task)
   at Nito.AsyncEx.AsyncContext.<>c__DisplayClass16_0`1.<Run>b__0(Task`1 t)
   at System.Threading.Tasks.ContinuationResultTaskFromResultTask`2.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException[TResult](Task`1 task)
   at Nito.AsyncEx.AsyncContext.Run[TResult](Func`1 action)
   at Abp.Threading.AsyncHelper.RunSync[TResult](Func`1 func)
   at SystemX.X.Reports.DetailedBankSalaryTransferReport.DetailedBankSalaryTransferReport_NeedDataSource(Object sender, EventArgs e) in D:\Work\src\SystemX System\src\X\SystemX.X.Reports\DetailedBankSalaryTransferReport.cs:line 43
   at Telerik.Reporting.Report.OnNeedDataSource(Object sender, EventArgs e)
   at Telerik.Reporting.Report.RaiseNeedDataSource(Object sender, EventArgs e)
   at Telerik.Reporting.Processing.Report.ResolveDataSourceDefinition(Report definition)
   at Telerik.Reporting.Processing.Report.<>c__DisplayClassd.<ResolveData>b__c()
   at Telerik.Reporting.Processing.DataItemResolveDataAlgorithm.ResolveData(String processingId, InMemoryState inMemoryState, MultidimensionalQuery query, Func`1 getDataCore, EvalObject expressionContext)
   at Telerik.Reporting.Processing.Report.ResolveData()
   at Telerik.Reporting.Processing.Report.ProcessItemCore()
   at Telerik.Reporting.Processing.Report.ProcessItem()
   at Telerik.Reporting.Processing.ReportItemBase.ProcessElement()
   at Telerik.Reporting.Processing.Report.ProcessElement()
   at Telerik.Reporting.Processing.ProcessingElement.Process(IDataMember dataContext)

I feel this is happening because Telerik is using second thread to some job with the report and this second thread doesn’t have AbpSession and also doesn’t have HttpRequest and so it has this issue. Edit: I tried to disable the EntityHistory using this

Configuration.EntityHistory.IsEnabled = false;

But it has no effect.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
ismcagdascommented, Feb 25, 2018

@iyhammad even if you disable EntityHistory, AbpSession is used here https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp.ZeroCore.EntityFrameworkCore/EntityHistory/EntityHistoryHelper.cs#L69.

So, as a temporary workaround, you can override CreateEntityChangeSet method of EntityHistoryHelper.

@acjh should we check if AbpSession is null or not ? An EntityHistory record might be created by a windows service or an app without a user. What do you think ?

0reactions
ismcagdascommented, Sep 30, 2019

@easyest could you share the full stack-trace ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Object reference not set to an instance of an object on c# EF6
Sometime I get this error message when i run my project in Hosting.There is no problem on the local server. Sometimes this error...
Read more >
Object Reference Not Set to an Instance of an Object
This exception is thrown when you try to access a member—for instance, a method or a property—on a variable that currently holds a...
Read more >
Why does "Object reference not set to an instance of ...
For example, I was trying to make a db call, with .net entity framework core. The column name was wrong, C# gave me...
Read more >
EXC nullreferenceexception: object reference not set to an ...
Playing on the newest experimental build, My friend closed the server to change the time scale, and I now can't join I tried:...
Read more >
Backups fail with error: Object reference not set to an ...
I set up a debugger, but was not even using that code on my backup. If that problem has somehow vanished, the “Unexpected...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found