Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

偶尔抛出异常,原因不明,抛出异常的位置:JsonNetReturnAttribute; System.ObjectDisposedException: Cannot access a disposed object. #247

Open
wangweinjcn opened this issue Apr 3, 2024 · 1 comment
Labels
等待反馈(needs feedback) 这意味着需要来自发起者的反馈(This means that feedback from the author is required)

Comments

@wangweinjcn
Copy link

wangweinjcn commented Apr 3, 2024

包的版本:

"WebApiClientCore" Version="2.0.4"
"WebApiClientCore.Extensions.NewtonsoftJson" Version="2.0.4"
"WebApiClientCore.Extensions.OAuths" Version="2.0.4"

代码定义:
[ServiceName("baseDataServer", "ut")]
[apiConsoleLog]
[JsonNetReturn]
public interface iCommTestApi
{

 /// <summary>
 /// 按条件获取全部数据
 /// </summary>
 /// <param name="queryParam"></param>
 /// <param name="objectName"></param>
 /// <returns></returns>
 [HttpPost("api/dbentityop/allRows/{objectName}/{returnFieldType}")]
 Task<IList<Dictionary<string, object>>> queryRows([JsonContent] baseQueryFormModel queryParam, [PathQuery] string objectName, int returnFieldType = 0);

}

现象:
偶尔会抛出异常
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'IServiceProvider'.
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ThrowHelper.ThrowObjectDisposedException()
at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
at WebApiClientCore.Attributes.JsonNetReturnAttribute.SetResultAsync(ApiResponseContext context)
at WebApiClientCore.Attributes.ApiReturnAttribute.OnResponseAsync(ApiResponseContext context)
at WebApiClientCore.Implementations.ApiRequestExecuter.HandleResponseAsync(ApiResponseContext context)

@EzrealJ
Copy link
Collaborator

EzrealJ commented Apr 7, 2024

能否提供一份最小可复现代码?

@EzrealJ EzrealJ added the 等待反馈(needs feedback) 这意味着需要来自发起者的反馈(This means that feedback from the author is required) label Apr 7, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
等待反馈(needs feedback) 这意味着需要来自发起者的反馈(This means that feedback from the author is required)
Projects
None yet
Development

No branches or pull requests

2 participants