Daily Usage Issues

Variables not in Context while debugging

Started by alexpolajenko on 4,991 views

This worked yesterday but ...

Today when I debug locally, some variables are not visible when I place my mouse over them. When I Watch them, VS2015 says they are not in context.

What is going on?

Edited

When NCrunch instruments assemblies output from your build system, it needs to reconstruct the PDB files containing debug information for these assemblies. The VS debugger then reads these PDB files to obtain debug information during the test run.

Over the last few years, MS have made the compiler considerably more complex with structures like async, where large amounts of code is generated and then masked by the PDB to appear to you as though your code is being debugged directly. If at any stage the data in the PDB doesn't match the structure expected by the VS debugger, the debugger may silently fail to evaluate certain values inside the method.

It's important to note that there is no published structure for any of this debug data. The VS debugger works by its own internal rules and seems to run its own guesswork. There were a number of these cases that came up after the VS2015 release and were later fixed. It's possible you've found a new one.

Are you able to reconstruct a method that can make the debugger behave in this way? If I can get some code that reproduces the issue, I stand a chance of being able to fix it.
I'm sorry that I can't be more helpful other than to say that "this happened to me, too". Because of the (needlessly) complex nature of my organization's code, I wouldn't know how to trigger this behavior in a simplified fashion, but I can confirm that this does happen. I thought it was my VS getting buggy on me, so I restarted VS. But alas, upon debugging the same test method, I was not able to view any information about local variables during debugging a unit test.

For what it's worth, we do use NUnit 3 (latest) and FakeItEasy.

Maybe I should have instructed NCrunch to rebuild the test project over again--maybe something got all out of whack in the caches/incremental build outputs?
fourpastmidnight wrote:
Maybe I should have instructed NCrunch to rebuild the test project over again--maybe something got all out of whack in the caches/incremental build outputs?


Every time I've seen this problem before, it has been triggered by either bugs/inconsistencies in the MS debugger, or the structure of the code being debugged. So I expect that nothing will be solved by rebuilding the project or clearing your NCrunch cache. To troubleshoot this, I'll need a self-contained and compilable project containing a method that demonstrates the problem, after which I then need to spend several days guessing at different reasons for why the debugger is acting the way it is :( PDB/Debug issues tend to be hard problems to solve.

Post a reply

Log in to reply.