I've got some breakpoints in Visual Studio, and whilst debugging in debug mode, they are being ignored.
This only occurs when variable is not used. EG
string s = "10;
string t = "Hi";
return s;
In the above, it will not stop if I set a break point on the string t
. Nor will it show 't' in the debug window. If I set a watch, the message in the Watch Window is
The name 't' does not exist in the current context
What I'm having to do as a work around is
string s = "10;
string t = "Hi";
string z = t; //pointless but the compiler now let's me focus on it
return s;
Please note, this happens for all variables throughout the entire program.
My own research suggests it's the JIT doing this; that it is optimizing the code for me and removing any overhead where it can, but I thought it would only do this in release mode? The point of me doing the above is so I can compare a new value against an old value as I'm re-factoring code.
My question is, can I turn off this compiler optimization?
This Visual studio 2010 debugger don't stop at Breakpoint? doesn't help.
All projects are .NET 4.0 (I know having different versions .NET can confuse the compiler)
Within the solution configruation, I have debug selected
In the Properties Window -> Debug is also set for Debug
In the Properties Window -> Build, has Optimize code unchecked
string s = "10;
and when the debugger hit it, move to next line withF10
key? Does it hit thestring t = "Hi";
line?