Lines of line trace lines are invalid with debug = false and compilerOptions = "/ debug: pdbonly"

I am using asp.net 3.5

In web.config, I have debug = false and compilerOptions = "/ debug: pdbonly" to compile with optimization and still get line numbers in my stacks. This works for the most part, but I had an error in the function in my App_Code folder, and the stack trace says that the error was on a line that cannot be an error.

I played around with my web.config settings a bit and found that if I set debug = true and compilerOptions = pdbonly, the stack trace says that the error is the line immediately after the error line. If I remove compilerOptions = pdbonly, the stack trace will report the correct line as an 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 any way to make this work right?

+4
source share
1 answer

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

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

+4
source

Source: https://habr.com/ru/post/1334124/


All Articles