abpframework / abp

Open Source Web Application Framework for ASP.NET Core. Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET and the ASP.NET Core platforms. Provides the fundamental infrastructure, production-ready startup templates, application modules, UI themes, tooling, guides and documentation.
https://abp.io
GNU Lesser General Public License v3.0
12.27k stars 3.32k forks source link

Volo.Abp.Http.Client, RemoteServiceErrorInfo, Object reference not set to an instance of an object #19587

Closed cethink closed 2 weeks ago

cethink commented 2 weeks ago

Is there an existing issue for this?

Description

[11:53:19 ERR] ---------- RemoteServiceErrorInfo ----------
{
  "code": null,
  "message": "对不起,在处理您的请求期间产生了一个服务器内部错误!!",
  "details": null,
  "data": {},
  "validationErrors": null
}

[11:53:19 ERR] Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
   at Volo.Abp.Http.Client.DynamicProxying.ApiDescriptionFinder.FindActionAsync(HttpClient client, String baseUrl, Type serviceType, MethodInfo method)
   at Volo.Abp.Http.Client.DynamicProxying.DynamicHttpProxyInterceptor`1.GetActionApiDescriptionModel(IAbpMethodInvocation invocation)
   at Volo.Abp.Http.Client.DynamicProxying.DynamicHttpProxyInterceptor`1.InterceptAsync(IAbpMethodInvocation invocation)   at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
   at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
   at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
   at Volo.Abp.Validation.ValidationInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
   at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
   at ES_ProductService.Controllers.ProductController.GetListAsync(PagedAndSortedResultRequestDto input) in D:\EcommerceSeckills\middles\ES_WebSite_Aggregate\Controllers\ProductController.cs:line 36
   at lambda_method1003(Closure, Object)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)

Reproduction Steps

No response

Expected behavior

No response

Actual behavior

No response

Regression?

No response

Known Workarounds

No response

Version

8.1.1

User Interface

Common (Default)

Database Provider

EF Core (Default)

Tiered or separate authentication server

None (Default)

Operation System

Windows (Default)

Other information

No response

realLiangshiwei commented 2 weeks ago

Please provider a small project to reproduce this.

cethink commented 2 weeks ago

Please provider a small project to reproduce this.

@realLiangshiwei EcommerceSeckills.zip

image

image

"RemoteServices": {
  "productservice": {
    "BaseUrl": "https://localhost:44385"
  }
}
context.Services.AddHttpClientProxy<IProductService>("productservice");
realLiangshiwei commented 2 weeks ago

First:

context.Services.AddHttpClientProxy<IProductService>("productservice");

The application uses productservice as the service name, but you have not configured it for the controller. The default service name is app and default.

image image

Second:

You changed the the default json PropertyNamingPolicy. You need to change the JsonSerializerOptions of the ApiDescriptionFinder as well.

public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
     .....
     ApiDescriptionFinder.DeserializeOptions.PropertyNamingPolicy = null;
}
cethink commented 2 weeks ago

@realLiangshiwei I'm sorry, I tried what you said, but it doesn't work. Can you upload the modified success code zip pack? Thanks

cethink commented 2 weeks ago

Thanks, I made a mistake, it works now! 👍