gpt4 book ai didi

asp.net-web-api - WebAPI 中的 TaskScheduler.UnobservedTaskException 取消了操作

转载 作者:行者123 更新时间:2023-12-02 21:15:46 26 4
gpt4 key购买 nike

最近,我在后端 API 应用程序中为每个 UnobservedTaskException 添加了错误日志记录。原因是某些 API 调用执行额外的任务,这些任务在我返回结果后完成,这就是为什么我无法跟踪操作(Web API 调用)级别的错误。

现在我收到很多“操作已取消”异常,但不知道该如何处理。我什至不确定这个异常是由我的API调用执行的任务引起的。

这是堆栈:

System.OperationCanceledException: The operation was canceled.
at System.Threading.CancellationToken.ThrowIfCancellationRequested()
at System.Web.Http.WebHost.HttpControllerHandler.<WriteBufferedResponseContentAsync>d__1b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.WebHost.HttpControllerHandler.<CopyResponseAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.WebHost.HttpControllerHandler.<ProcessRequestAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.TaskAsyncHelper.EndTask(IAsyncResult ar)
at System.Web.HttpApplication.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar)

有什么想法如何调试它吗?

最佳答案

任务取消异常通常来自于中止请求的任务。我们正在跟踪一个错误,该错误将在 5.2 中修复,这些错误不会显示在异常记录器中。因此,通常您可以安全地忽略这些。

您可以在 https://www.myget.org/gallery/aspnetwebstacknightly 上获取夜间构建版本以验证这是否可以解决您的问题。

以下是该错误的链接:http://aspnetwebstack.codeplex.com/workitem/1797

关于asp.net-web-api - WebAPI 中的 TaskScheduler.UnobservedTaskException 取消了操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23360375/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com