stack trace line numbers are wrong with debug=false and compilerOptions="/debug:pdbonly"
<p>I'm using asp.net 3.5</p>

<p>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.  </p>

<p>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.</p>

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

<p>Is there a way to make this work right?</p>
