4

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?

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.