How can I disable compiler optimization in C#?
before you start to change the settings of the project which might find its way to production verify that your solution configuration is set for Debug and not Release.
I had the same issue and then I saw that it was set to Release by mistake...
At the command line (csc), /optimize-
In the IDE, project properties → build → "optimize code"
For some JIT optimizations, you can use [MethodImpl(...)]
In Visual Studio I believe you can just create a debug build, but it includes additional debug information. Project Properties (right click on project in solution) gives you access to the controls governing compilation.
If you build on the command line with csc.exe see the /optimize parameter docs. If you don't specify /optimize then the assembly should not be optimized.
You can disable the optimizations in runtime using an .ini file: http://msdn.microsoft.com/en-us/library/9dd8z24x.aspx
Enter the following text into you .ini [for example Explorer.ini]
[.NET Framework Debugging Control]
GenerateTrackingInfo=1
AllowOptimize=0
Set Configurations to All Configurations
Set Optimized code checkbox to unchecked