2

When I use a watch I get this error message:

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.

It's really strange because I can only get intellisense in some parts of the application. The issue originally started when I couldn't step into my methods, so through searching. I turned off the just my code option in the debugger.

So far I have tried:

  1. Restart machine
  2. Clean + Rebuild VS2015
  3. I have turned off all optimisations for debugging

I have no idea what to do. Can anyone help?

EDIT:

Code where it happens:

 public IList<string> PopulateFilterList(string selectedFields) {
            IList<string> ExcludedFields = _homeRepository.GetExcludedFields();
            Type t = typeof(Invoice);

            return null;
        }

I'm just trying to look at t

Edit: If I check the option 'Suppress JIT optimisation on module load' in the debugger I get intellisense. I get intellisense

Maverick
  • 1,396
  • 5
  • 22
  • 42
Andrew Kilburn
  • 2,251
  • 6
  • 33
  • 65
  • You have turned of all optimisations for debugging, but are you in the Debug solution configuration? – Maarten Jul 27 '16 at 10:08
  • Can you show some code where the behaviour is happening? – Maarten Jul 27 '16 at 10:09
  • 1
    I barely remember something like that happening to me once, but i think that it got solved with a clean + rebuild. Anyway try to delete the /bin and /obj contents and see if that helps – Pikoh Jul 27 '16 at 10:56

1 Answers1

5

In VS 2015 Community Edition

go to Debug->Options or Tools->Options

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

if this doesn't work check that all projects in the solution have the option "Optimize code" un-ticked in the project properties.

Ben Jones
  • 699
  • 4
  • 18