Cannot obtain value of local or argument as it is not available at this instruction pointer, possibly because it has been optimized away

curiousity picture curiousity · Nov 29, 2011 · Viewed 127.4k times · Source

Visual Studio 2010 kills (there is no other word) data in one of the arguments of the function in the unsafe block. What could cause this error? The following message shows by the debugger.

Cannot obtain value of local or argument as it is not available at this instruction pointer, possibly because it has been optimized away.

Answer

Karthik picture Karthik · Aug 26, 2014

Go to Project Properties and under Build Make sure that the "Optimize Code" checkbox is unchecked.

Also, set the "Debug Info" dropdown to "Full" in the Advanced Options (Under Build tab).