Debugging whilst paused and 'cannot evaluate expression'

Viewed 33247

Using Visual Studio, after attaching to a Process and pressing Pause (Break-All), you switch to the desired thread and use the Quick Watch window to check out some data, say

MySingletonClass.Instance.Data

Sometimes I either get this:

Cannot evaluate expression because the current thread is in a sleep, wait, or join

or this (when trying to view certain properties of the data):

Cannot evaluate expression because a native frame is on top of the call stack.

Quite frankly, I don't care, I just want to see the data! I know there are various ways to get around this, namely:

  1. Setting a breakpoint on the thread and waiting till it gets hit (cumbersome, not always possible)
  2. Taking a dump of the process and loading back into VS (even then I still get the 2nd error)
  3. windbg

Given you could see this data if you presumably used windbg why is it we all can't take advantage of the much easier and prettier VS to inspect objects when attaching to a process?

7 Answers
Related