c# - System.IO.FileNotFoundException 上 System.Runtime.CompilerServices.AsyncTaskMethodBuilder
问题描述
我有以下代码
try
{
using (var client = HttpClientBuilder.CreateClient(PingTimeoutMilliseconds, true))
{
var response = await Policy
.Handle<Exception>(ex => ex is HttpRequestException || ex is TaskCanceledException)
.WaitAndRetryAsync(new[]
{
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(3)
}, (ex, timeSpan, retryCount, context) =>
{
loggerService.Log(ex);
loggerService.Log($"Ping request failed. Waiting {timeSpan} seconds before next retry. Retry attempt {retryCount}");
})
.ExecuteAsync(() => client.SendAsync(new HttpRequestMessage(HttpMethod.Head, uri)));
IsInternetAvailable = response.IsSuccessStatusCode;
return response.IsSuccessStatusCode;
}
}
一些客户抱怨异常
Uitzonderings 信息:System.IO.FileNotFoundException
System.IO.FileNotFoundException
bij Showpad.OutlookDesktopAddIn.Infrastructure.Helpers.PingHelper+<IsInternetAvailableAsync>d__5.MoveNext()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].Start[[Showpad.OutlookDesktopAddIn.Infrastructure.Helpers.PingHelper+<IsInternetAvailableAsync>d__5, Showpad.OutlookDesktopAddIn, Version=2.7.6.0, Culture=neutral, PublicKeyToken=null]](<IsInternetAvailableAsync>d__5 ByRef)
我可能怀疑第 5 行等待策略的 Polly 库可能有问题(因为存在 IO 异常)
using Polly;
解决方案
推荐阅读
- java - 需要 MimeBodyPart 中的 setFileName 吗?
- python - 在熊猫中按位置提取数字?
- apache-spark - 将 Array[(Any, (Any, Any))] 转换为具有 2 列的 spark 数据帧
- node.js - 如何测试包含异步函数的函数?
- regex - 如何在 HTML 文本输入中使用正则表达式模式
- r - 合并可能是或可能不是同一个人的行(带有字符数据)
- angularfire2 - Angular Firestore 无需订阅即可获取文档
- python-3.x - 如何将文本用作字典
- c# - 从数据库中获取 PDF 文件并将其显示在 Windows 窗体 C#
- javascript - 如何从游戏应用程序的聚合管道中的总点数计算排名