开发者

stack trace line numbers are wrong with debug=false and compilerOptions="/debug:pdbonly"

开发者 https://www.devze.com 2023-02-02 12:16 出处:网络
I\'m using asp.net 3.5 In web.config, I have 开发者_如何转开发debug=false and compilerOptions=\"/debug:pdbonly\" to compile with optimizations and still get line numbers in my stack traces.This works

I'm using asp.net 3.5

In web.config, I have 开发者_如何转开发debug=false and compilerOptions="/debug:pdbonly" to compile with optimizations and still get line numbers in my stack traces. This works for the most part, but I had a bug in a function in my App_Code folder and the stack trace said the error was on a line that couldn't possibly be an error.

I played with my web.config settings a little bit and found that if I set debug=true and compilerOptions=pdbonly, the stack trace says the error is the line directly after the line with the bug. If I remove the compilerOptions=pdbonly, the stack trace reports the correct line as the error.

//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;  

Is there a way to make this work right?


Compiler optimizations can affect the line numbering reported in the stack trace. You can set the compiler option /optimze- to disable them, then your stack trace line numbers should be correct.

For example: <compiler compilerOptions="/optimze- /debug:pdbonly"/>

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号