A curious case of Visual Studio 2010 debugger(it can not hit a break point)
This is the code that reproduces the problem:
class Program
{
static void Main(string[] args)
{
bool b = false;
if (b)
{
List<string> list = new List<string>();
foreach (var item in list)
{
}
}
else
{
Console.WriteLine("1");
}
Console.WriteLine("2");//add a break point here in VS2010
}
//1. configuration: release
//2. platform target: x64 or Any Cpu
//3. debug info: pdb only or full
//4. OS: Win7 x64
//5. optimize code: enabled
}
Add a break point to the last statement of the code, then debug it in vs2010, you'll see that the break point can not be hit.
To reproduce this curious case, you'll need to meet the following conditions:
- Operation system: windows 7 x64;
- VS build configuration: release;
- VS build platform target: x64 or Any Cpu;
- VS build debug info: pdb only or full;
- VS build optimize code: enabled;
I am not sure those conditions are sufficient to reproduce it, but it's how my machine was configured when I found this issue.
Why is the debugger not able to hit the break point?
Thanks in advance.!
And if you can reproduce this issue, please consider to votevoting on this post.