aspnetboilerplate: Null exception in CacheBase

Hi when i run my unit test as a batch the first unit-test works but the second one fail at the following line : response.Results = certificates.MapTo<List<PostResult>>();

with the following stack trace :

at Abp.Runtime.Caching.CacheBase.<GetAsync>d__19.MoveNext() in D:\Github\aspnetboilerplate\src\Abp\Runtime\Caching\CacheBase.cs:line 98 — End of stack trace from previous location where exception was thrown — at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Runtime.Caching.CacheExtensions.<GetAsync>d__52.MoveNext() in D:\Github\aspnetboilerplate\src\Abp\Runtime\Caching\CacheExtensions.cs:line 38 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Configuration.SettingManager.<GetUserSettingsFromCache>d__40.MoveNext() in D:\Github\aspnetboilerplate\src\Abp\Configuration\SettingManager.cs:line 430 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Configuration.SettingManager.<GetReadOnlyUserSettings>d__38.MoveNext() in D:\Github\aspnetboilerplate\src\Abp\Configuration\SettingManager.cs:line 403 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Configuration.SettingManager.<GetSettingValueForUserOrNullAsync>d__35.MoveNext() in D:\Github\aspnetboilerplate\src\Abp\Configuration\SettingManager.cs:line 373 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Abp.Configuration.SettingManager.<GetSettingValueInternalAsync>d__31.MoveNext() in D:\Github\aspnetboilerplate\src\Abp\Configuration\SettingManager.cs:line 235 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException[TResult](Task1 task) at System.Threading.Tasks.ContinuationResultTaskFromResultTask2.InnerInvoke() at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException[TResult](Task1 task) at Nito.AsyncEx.AsyncContext.Run[TResult](Func1 action) at Abp.AutoMapper.AutoMapExtensions.<>c__DisplayClass2_04.<CreateMultiLingualMap>b__0(TMultiLingualEntity source, TDestination destination, ResolutionContext context) in D:\Github\aspnetboilerplate\src\Abp.AutoMapper\AutoMapper\AutoMapExtensions.cs:line 54 at lambda_method(Closure , List1 , List1 , ResolutionContext )

I think it’s from the line : var defaultLanguage = multiLingualMapContext.SettingManager .GetSettingValue(LocalizationSettingNames.DefaultLanguage);

In the Automaper Extension file

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (17 by maintainers)

Most upvoted comments

I found out where my NullRef came from. In the AutoMaperExtension in the method CreateMultilingualMap in the BeforeMap there is a call to SettingManager.GetSettingValue() which end’s up calling the CacheBase GetAsync Method. And the method throw an error and it trys to log it but the Logger was null. :

            try
            {
                item = await GetOrDefaultAsync(key);
            }
            catch (Exception ex)
            {
                Logger.Error(ex.ToString(), ex);
            }

I’ve added this line to my Preinitialize method of my test module :

this.Configuration.ReplaceService<ILogger, NullLogger>(DependencyLifeStyle.Transient);