本文介绍了发生了mscorlib.dll的PingException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在尝试从.csv文件中读取ip地址并使用PingAsync类ping这些地址。但是我在以下行中获得了以上异常。I'm trying to read ip address from .csv file and ping those addresses using PingAsync class. But I'm getting above exception in the following line.private static async Task AsyncPingTask(List<string> ipaddress) { try { Console.WriteLine("Ping Started"); StringBuilder pingStringBuilder = new StringBuilder(); var pingTasks = ipaddress.Select(ip => { using (var ping = new Ping()) { return ping.SendPingAsync(ip); } }).ToList(); Console.WriteLine("Ping Completed"); await Task.WhenAll(pingTasks); foreach (var pingReply in pingTasks) { pingStringBuilder.Append(pingReply.Result.Address); pingStringBuilder.Append("-->"); pingStringBuilder.Append(pingReply.Result.Status); pingStringBuilder.Append("-->"); pingStringBuilder.Append(pingReply.Result.RoundtripTime.ToString()); pingStringBuilder.AppendLine(); } Console.WriteLine(pingStringBuilder.ToString()); pingStringBuilder.Clear(); } catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); throw; } }public static void Main() { List<string> address = new List<string>(); Task t = Task.Run(() => { var reader = new StreamReader(File.OpenRead(Environment.CurrentDirectory+@"\address.csv")); while (!reader.EndOfStream) { var lines = reader.ReadLine(); var values = lines.Split(';'); address.Add(values[0]); } }); Console.WriteLine("List COunt is {0}",address.Count); Stopwatch timeSpan=Stopwatch.StartNew(); t.Wait(); AsyncPingTask(address).Wait(); Console.WriteLine(timeSpan.ElapsedMilliseconds); Console.ReadLine(); } 如果我有任何错误请指导我。If I done any mistake please guide me.推荐答案 这篇关于发生了mscorlib.dll的PingException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-01 19:49