try
            {
                var a = Convert.ToInt32("AA");
            }
            catch (Exception ex)
            {
                                StackTrace st = new StackTrace(ex, true);
                string strErrorLine = st.GetFrame(st.FrameCount - 1).GetFileLineNumber().ToString();
                string currentName = st.GetFrame(st.FrameCount - 1).GetMethod().Name;
                string callName = new System.Diagnostics.StackTrace(ex, true).GetFrame(0).GetFileName();
                string strBodyMsg = "";
                strBodyMsg += "訊息提示: " + ex.Message.ToString() + Environment.NewLine;
                strBodyMsg += "錯誤行數: " + strErrorLine + Environment.NewLine;
                strBodyMsg += "錯誤檔案: " + callName + Environment.NewLine;
                strBodyMsg += "呼叫方法: " + currentName + Environment.NewLine;
                MessageBox.Show(strBodyMsg);
            }我要如何在deployment 情況下,return 真實錯誤欄位

解决方案 »

  1.   

    Debug.WriteLine输出,可在debug调试输出
      

  2.   

    StackTrace 在Debug生成配置里才会提供详细的信息。默认情况下, 用Debug 生成会包括调试符号,而 Release 生成则不会。调试符号包含很多用于StackFrame 和 StackTrace对象的信息,如文件、方法名、行号和列号等。其实,Release 模式优化了代码而且没有 Program DataBase 文件(.pdb)在 Relese 模式里Property->Build->Define Debug Constant(勾上)Property->Build->Optmize Code(不勾)p.s 在大陆的论坛,请使用大陆的用语
      

  3.   

    Property->Build->Define Debug Constant(勾上)Property->Build->Optmize Code(不勾) 用了 RETURN 还是 0
      

  4.   

    部属成 msi,然后安装  RETURN  0