使用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;
    }
posted @ 2012-03-21 22:31  Darren.Xiang  阅读(407)  评论(0编辑  收藏  举报