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

Open
#247 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
csharp

Research direction

Start with JsonNetReturnAttribute.SetResultAsync and follow the ApiReturnAttribute.OnResponseAsync and ApiRequestExecuter.HandleResponseAsync calls shown in the stack trace. Investigate the IServiceProvider lifetime during intermittent response handling and confirm completion by reproducing the failure and verifying that disposed-provider access no longer occurs.

Written by the indexing model from the issue text.

Description

等待反馈(needs feedback)

包的版本:

"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)

Dominant language
C#
Stars
2.1k
Forks
445
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnetcore/WebApiClient

All issues in dotnetcore/WebApiClient

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.