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

visual studio 2019 debugger not showing variable values
the value of the local or argument is unobtainable at this time
cannot evaluate expression because the code of the current method is optimized.
variable is optimized away and not available.
visual studio 2017 turn off optimization
visual studio code debugger optimized out
c# debug optimized away
the code being debugged was optimized

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.

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).

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

Also In VS 2015 Community Edition

go to Debug->Options or Tools->Options

and check Debugging->General->Suppress JIT optimization on module load (Managed only)

Fixed – Cannot obtain value of local or argument as it not available at, Fixed – Cannot obtain value of local or argument as it not available at the instruction pointer, possibly because it has been optimized away  Fixed – Cannot obtain value of local or argument as it not available at the instruction pointer, possibly because it has been optimized away while debugging in Visual Studio Hi, Was facing this the above issue while trying to debug the code.

If you compile with optimizations enabled, then many variables will be removed; for example:

SomeType value = GetValue();
DoSomething(value);

here the local variable value would typically get removed, keeping the value on the stack instead - a bit like as if you had written:

DoSomething(GetValue());

Also, if a return value isn't used at all, then it will be dropped via "pop" (rather than stored in a local via "stloc", and again; the local will not exist).

Because of this, in such a build the debugger can't get the current value of value because it doesn't exist - it only exists for the brief instant between GetValue() and DoSomething(...).

So; if you want to debug... don't use a release build! or at least, disable optimizations while you debug.

Debug not displaying local variable content, Cannot obtain value of the local variable or argument because it is at this instruction pointer, possibly because it has been optimized away. Cannot obtain value of local or argument as it is not available at this instruction pointer, possibly because it has been optimized away. Answers: Go to Project Properties and under Build Make sure that the “Optimize Code” checkbox is unchecked.

http://www.guntucomputerhacks.blogspot.com.au/2014/07/cannot-obtain-value-of-local-or.html

This worked for me in visual studio 2013.

All you have to do is..

  1. Right mouse click on the project that you can't debug.
  2. Go to project proprieties.
  3. Click on build menu.
  4. Click on advanced button.
  5. Set debug info dropdown value to full.
  6. Rebuild your project.

VS2017 15.9.4 debugger still not showing variable values on hover , From that point on forward I cannot hover over variables to see their values "​Cannot obtain value of the local variable or argument because it is not available at this instruction pointer, possibly because it has been optimized away." or “​Suppress JIT optimization on module load” in Debug->Options  While debugging in Visual Studio 2015, many variables are not available. When you try to see a variable's value, Visual Studio tells you, "Cannot obtain value of the local variable or argument because it is not available at this instruction pointer, possibly because it has been optimized away."

I just ran into this and I was running under Release build configuration instead of Debug build configuration. Once I switched back to Debug my variable showed in the watch again.

Cannot obtain value of local or argument as it is not available at this , "Cannot obtain value of the local variable or argument because it is not available at this instruction pointer, possibly because it has been optimized away." will be optimized away and will not be available during debugging.". "Cannot obtain value of local or argument 'ArrLine' as it is not available at this instruction pointer, possibly because it has been optimized away." I am somewhat confused at how my Array can simply be "optimized away" in such a basic function.

Defeat the Evil Optimized Away Overlord / OzCode Feature , Cannot obtain value of local or argument as it is not available at this instruction pointer, possibly because it has been optimized away. Cannot obtain value of local or argument as it is not available at this instruction pointer, possibly because it has been optimized away. Hi All I couldn't debug my C# class library project due to this issue for last few month.

Debugging ASP.NET Source From Visual Studio · Issue #8375 , Cannot obtain value of local or argument as it is not available at this instruction pointer, possibly because it has been optimized away. visual studio 2019  Cannot obtain value of local or argument '<this>' as it is not available at this instruction pointer, possibly because it has been optimized away. Also, when I try to set a break point condition with this, the debugger says:

is encountering the "Cannot obtain value of local or argument as it is not available at this instruction pointer, possibly because it has been optimized away. "Cannot obtain value of local or argument 'xxxxx' as it is not available at this instruction pointer, possibly because it has been optimized away." Sure enough, looking at the "Debug->Windows->Modules" window and finding "System.Web.dll" in the list of loaded modules, it shows that the symbols have been loaded and that the "System.Web.dll

Comments
  • i have exactly the same problem and i'm using Debug build. Cannot obtain value of local or argument '<this>' as it is not available at this instruction pointer, possibly because it has been optimized away. System.Threading.Tasks.TaskExceptionHolder
  • Oops I just had release selected by mistake..
  • I'm having this problem in VS 2017 and I've followed all the instructions in the posts below. Are there any other options?
  • Don't forget Menu Build -> Configuration Manager. Configuration needs to be set to Debug there or you still get the problem.
  • First, check that the Build Configuration is Debug, not Release.
  • By the way, if you want to test it in Release mode, you can add "Debugger.Launch();" in the code
  • Did both steps and changed the configuration from "Release" to "Build". Worked on Visual Studio 2017 Community Edition.
  • If you have VS 2017 both the accepted answer and the answer by xyq.384.b will help. For me xyq.384.b answer was the fix as it was JIT debugger that was suppressing the pointer...I'm sorry JIT "optimized" it...
  • After switching to debug configuration I discovered the optimize code box was already unchecked. Lesson learned: Don't debug in release configuration mode.
  • This solved my issue after having applied all the solutions mentioned above.
  • None of the suggested answers works for me. My variables are still optimized away...
  • No idea why this just suddenly started happening.. but this fixed it!
  • Holy crap, this also fixed it for me in VS2017 Community! No idea when or how this option got deselected...
  • Works like a champ!