【问题标题】:stack trace line numbers are wrong with debug=false and compilerOptions="/debug:pdbonly"堆栈跟踪行号错误,debug=false 和 compilerOptions="/debug:pdbonly"
【发布时间】:2011-06-03 01:44:07
【问题描述】:

我正在使用 asp.net 3.5

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

我稍微使用了我的 web.config 设置,发现如果我设置 debug=true 和 compilerOptions=pdbonly,堆栈跟踪显示错误是错误所在行之后的行。如果我删除 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;  

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

【问题讨论】:

    标签: c# asp.net


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2014-04-29
      • 1970-01-01
      • 1970-01-01
      • 2011-08-10
      • 1970-01-01
      • 1970-01-01
      • 2018-09-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多