最近我在我的后端API应用程序中为每个UnobservedTaskException添加了错误记录.
原因是某些API调用会执行其他任务,这些任务在我返回结果后完成,这就是为什么我无法跟踪操作(web api调用)级别的错误.
原因是某些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上获取每晚构建以验证这可以解决您的问题.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。