VictorTzeng / Zxw.Framework.NetCore.Demo

Demo for the Zxw.Framework.NetCore repository.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AspectCore.DynamicProxy.AspectInvocationException: Exception has been thrown by the aspect of an invocation. ---> Object reference not set to an instance of an object.

wannvmi opened this issue · comments

使用异步方法加 RedisCacheMemoryCache Attribute会报错

                    if (context.ServiceMethod.IsReturnTask())
                    {
                        context.ReturnValue = Task.FromResult(JsonConvert.DeserializeObject(value,
                            context.ServiceMethod.ReturnType.GenericTypeArguments[0]));
                    }

context.ReturnValue是空值

"Message": "Exception has been thrown by the aspect of an invocation. ---> Object reference not set to an instance of an object.."
"InnerException":"Object reference not set to an instance of an object.",

J22$SM(N $@@LL1PJ~K_QTA
returnValue Id = 405, Status = RanToCompletion, Method = "{null}", Result = "19"

异步读取redis key 返回null

TIM截图20190613105419

异步写入报错

TIM截图20190613105705

同步方法都是可用的

TIM截图20190613104537
TIM截图20190613104748

AspectCore.DynamicProxy.AspectInvocationException: Exception has been thrown by the aspect of an invocation. ---> Object reference not set to an instance of an object.. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at ActualCombat.Hotel.Core.Attributes.RedisCacheAttribute.Invoke(AspectContext context, AspectDelegate next) in E:\XWwork\Git\AC.Hotel\src\ActualCombat.Hotel.Core\Attributes\RedisCacheAttribute.cs:line 61
   at AspectCore.DynamicProxy.AspectActivator.InvokeTask[TResult](AspectActivatorContext activatorContext)
   --- End of inner exception stack trace ---
   at AspectCore.DynamicProxy.AspectActivator.InvokeTask[TResult](AspectActivatorContext activatorContext)
   at ActualCombat.Hotel.Api.Controllers.UserController.GetCountAsync() in E:\XWwork\Git\AC.Hotel\src\ActualCombat.Hotel.Api\Controllers\UserController.cs:line 56
   at lambda_method(Closure , Object )
   at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult()
   at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()