debug=false 和 compilerOptions="/debug:pdbonly" 时堆栈跟踪行号错误

2024-01-03

我正在使用 ASP.NET 3.5

在 web.config 中,我有 debug=false 和 compilerOptions="/debug:pdbonly" 来进行优化编译,并且仍然在堆栈跟踪中获取行号。这在大多数情况下都有效,但我的 App_Code 文件夹中的一个函数有一个错误,堆栈跟踪表明该错误位于不可能是错误的行上。

我稍微调整了一下 web.config 设置,发现如果我设置 debug=true 和 compilerOptions=pdbonly,堆栈跟踪显示错误是在有 bug 的行之后的那一行。如果我删除 compilerOptions=pdbonly,堆栈跟踪会将正确的行报告为错误。

//the actual bug  (only reported when debug=true and no compiler options set)
var dt = new DateTime(-1,-1,-1);         

//
//...lots of non-buggy code between
//

//the bug according to the stack trace when 
//   debug=false and compilerOptions="/debug:pdbonly"
var ts = TimeSpan.Empty;  

有没有办法让这项工作正确进行?


编译器优化可能会影响堆栈跟踪中报告的行编号。您可以设置编译器选项/优化-要禁用它们,那么您的堆栈跟踪行号应该是正确的。

例如:<compiler compilerOptions="/optimze- /debug:pdbonly"/>

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

debug=false 和 compilerOptions="/debug:pdbonly" 时堆栈跟踪行号错误 的相关文章

随机推荐