Erroe line 在deployment下,return0

test104 2018-12-31 06:24:26
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 真實錯誤欄位
...全文
277 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
test104 2019-01-20
  • 打赏
  • 举报
回复
部属成 msi,然后安装 RETURN 0
test104 2019-01-20
  • 打赏
  • 举报
回复
Property->Build->Define Debug Constant(勾上)

Property->Build->Optmize Code(不勾)

用了 RETURN 还是 0
我姓区不姓区 2019-01-02
  • 打赏
  • 举报
回复
StackTrace 在Debug生成配置里才会提供详细的信息。默认情况下, 用Debug 生成会包括调试符号,而 Release 生成则不会。调试符号包含很多用于StackFrame 和 StackTrace对象的信息,如文件、方法名、行号和列号等。 其实,Release 模式优化了代码而且没有 Program DataBase 文件(.pdb) 在 Relese 模式里 Property->Build->Define Debug Constant(勾上) Property->Build->Optmize Code(不勾) p.s 在大陆的论坛,请使用大陆的用语
平底锅锅锅 2019-01-02
  • 打赏
  • 举报
回复
Debug.WriteLine输出,可在debug调试输出

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧