Sooner or later you may run into a situation where you need to evaluate a local variable under debugger and all you get is this:
"Cannot obtain value of local or argument ‘whatever’ as it is not available at this instruction pointer, possibly because it has been optimized away’.
Well, it turns out there are two different tricks to solve such problems:
Shawn Burke blogs about How to disable optimizations when debugging Reference Source. In a nutshell, you need to:
- Start VS with the Environment Variable COMPLUS_ZapDisable=1
- Disable the VS Hosting Process (.vshost.exe) before you start debugging
[.NET Framework Debugging Control]
He also points to the MSDN article http://msdn.microsoft.com/en-us/library/9dd8z24x.aspx (Making an Image Easier to Debug).
To be frank, this tip didn’t work for me for some reason, but I guess it’s still worth mentioning.
Hope this helps!