I have ASP .Net Web Application in C# (no MVC or WebForms) compiled in Release mode for AnyCPU, pdb files are enabled and deployed with application.
When enable 32-bit applications
on AppPool has the default value of False
the stack trace of the exception has correct line numbers.
When the flag is set to True
the stack trace has incorrect line numbers.
Just to make it clear the only thing I change is the value for enable 32-bit applications
flag in AppPool configuration of my web application.
I have tried this on two machines:
- Windows 8 with IIS 8.5.9600.16384
- Windows Server 2008 R2 with IIS 7.5.7600.16385
In my particular case it is OK to just reconfigure AppPool (we have already migrated from x86 to AnyCPU and this obsolete configuration is just a mistake), but I am still interested why does this happen? (may be there is some bug in IIS, I was not able to find this behavior mentioned anywhere).
Update: it seems I have figured it out, but this is a temporary reprieve:
- The problems is almost certainly due to code optimization (I have written code in such a way, that rules out other options: jitter reorders functions. This is not a compiler because I do not recompile application between tests).
- Most of the optimization is done by jitter, and x86 optimizations are more aggressive than x64 optimizations, thus the difference in resulting code. When Microsoft decides to make x64 optimizations more agressive lines will be broken.