这是您可以使用的一种方法:
try
{
//Some commands that can raise an exception
}
catch (Exception e)
{
Exception inner = e.InnerException ?? e;
while (inner.InnerException != null)
{
inner = inner.InnerException;
}
//inner exception will contain the innerest exception
}