使用StackTrace类获取更详细的Exception信息
try
{
string x = "";
int y = int.Parse(x);
}
catch (Exception ex)
{
System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace(ex, true);
System.Diagnostics.StackFrame[] sfs = st.GetFrames();
foreach (var item in sfs)
{
//Get stackFrame info here...
}
throw ex;
}
浙公网安备 33010602011771号