PingException,如何获取异常原因?

问题描述 投票:0回答:1

我正在开发一个 C# 项目。 我正在使用

Ping
来 ping 多个远程系统,有时我会看到
PingException
引发,但这本身并不是很有帮助,因为它似乎没有给出引发异常的任何原因。

我看过: https://learn.microsoft.com/en-us/dotnet/api/system.net.networkinformation.pingException?view=net-8.0

备注中:

Applications should check the inner exception of a PingException object to identify the problem.

我该怎么做?

c# ping pingexception
1个回答
0
投票

要获取实际的异常,请使用

InnerException.Message

© www.soinside.com 2019 - 2024. All rights reserved.