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.

Abp.EntityHistory.EntityHistoryHelperBase.IsAuditedPropertyInfo: Object reference not set ...

See original GitHub issue

Hi community 😃 I’ve problem with auditing exception for PropertyInfo object. Abp version 6.4.0 .NetCore 5

Exeption Object reference not set to an instance of an object

at Abp.EntityHistory.EntityHistoryHelperBase.IsAuditedPropertyInfo(PropertyInfo propertyInfo) at Abp.EntityHistory.EntityHistoryHelper.GetPropertyChanges(EntityEntry entityEntry, Boolean auditedPropertiesOnly) at Abp.EntityHistory.EntityHistoryHelper.CreateEntityChangeSet(ICollection1 entityEntries) at Abp.Zero.EntityFrameworkCore.AbpZeroCommonDbContext3.<SaveChangesAsync>d__130.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at Abp.EntityFrameworkCore.Uow.EfCoreUnitOfWork.<SaveChangesAsync>d__12.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Authorization.Users.AbpUserStore2.<>c__DisplayClass46_0.<<CreateAsync>b__0>d.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() at Abp.Domain.Uow.UnitOfWorkManagerExtensions.<WithUnitOfWorkAsync>d__31.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() at Abp.Authorization.Users.AbpUserStore2.<CreateAsync>d__46.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.AspNetCore.Identity.UserManager1.<CreateAsync>d__73.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() at Abp.Authorization.Users.AbpUserManager2.<CreateAsync>d__37.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.AspNetCore.Identity.UserManager1.<CreateAsync>d__78.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()

I’ve readed in EFCore documentation /// <summary> /// Gets the <see cref="PropertyInfo" /> for the underlying CLR property that this /// object represents. This may be null for shadow properties or properties mapped directly to fields. /// </summary> PropertyInfo PropertyInfo { get; }

and that is a problem, because my entity looks this:

private string _gender; [NotMapped] [DisableAuditing] public GenderEnum Gender { get => GenderEnum.Parse(_gender); set => _gender = value?.Value; }

  1. [DisableAuditing] not help
  2. I use [NotMapped] attribute because propery is mapped to encapsulated filed and GenderEnum class is not a EF table object public class UserEntityTypeConfiguration : IEntityTypeConfiguration<User> { public void Configure(EntityTypeBuilder<User> builder) { builder.Property<string>("_gender").HasColumnName("Gender"); } } `
  3. When i change my entity to public string Gender { get; set; } without explicitly encapsulation EntityHistoryHelper doesn’t throw any errors.

So i thing we have a problem with PropertyInfo = null

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ismcagdascommented, Oct 7, 2021

@1jedrzej1 thanks, we will check this.

0reactions
ismcagdascommented, Dec 16, 2021

@ahmedtolba1984 we will test this again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

System.NullReferenceException: 'Object reference not set to ...
I have a background job where I am attempting to select records from a trap table.
Read more >
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 >
Null Reference Exception When Trying To Create User- ...
NullReferenceException : Object reference not set to an instance of an object. at Abp.EntityHistory.EntityHistoryHelper.
Read more >
Manage Nuget Packages give Object Reference not set to ...
Getting the Object Reference not set to an instance of an object when trying to do scaffolding on a asp.net core mvc project...
Read more >
Aspnetboilerplate Versions
EntityHistory.EntityHistoryHelperBase.IsAuditedPropertyInfo: Object reference not set . ISSUE [#6272](https://github.com/aspnetboilerplate/aspnetboilerplate/ ...
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