Immediate Window "Unable to Evaluate the Expression"

rbulph

Junior Contributor
Joined
Feb 17, 2003
Messages
397
If I interrupt debugging by clicking the "Break All" (") toolbar button, I can't evaluate any expressions in the Immediate Window. I get the message "Unable to Evaluate the Expression" whenever I try. But if I call the Stop statement in code, then I can. So I end up putting code in my form like:

Code:
   Private Sub picCanvas_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles picCanvas.DoubleClick

        If System.Diagnostics.Debugger.IsAttached Then Stop

    End Sub
so that I can access the Immediate Window and query values. Is this right that I have to do this?
 
Why don't you just put a break point on the line(s) you want to cause the app to break at? Doing a Break All will often result in the application being put into debug mode but outside of any actual runable .Net code - that is why you cannot evaluate any expressions etc.
 
PlausiblyDamp said:
Why don't you just put a break point on the line(s) you want to cause the app to break at? Doing a Break All will often result in the application being put into debug mode but outside of any actual runable .Net code - that is why you cannot evaluate any expressions etc.

Because sometimes I don't have a particular point at which I want execution to stop. I'm running it and I just want to go into it to query some value.

I don't know about the application breaking outside any runnable code - it can't even evaluate "? 7 + 3" for me, which I wouldn't think requires any runnable code. But anyway I can live with my suggestion above.
 
PlausiblyDamp said:
? 7 + 3 worked just fine for me when I hit CTRL + BREAK...
Yes, it seems that if you hit CTRL + BREAK when the current form in the application has focus it works OK, but if you break by pressing the button in the toolbar or by hitting CTRL + BREAK while looking at the code, it doesn't work.
 
I tried pausing from the IDE and it worked fine for me. Is the code editor highlighting a line of code when you break (a "call return", it will be a different color than active line and have an arrow in the breakpoint margin)?
 
marble_eater said:
I tried pausing from the IDE and it worked fine for me. Is the code editor highlighting a line of code when you break (a "call return", it will be a different color than active line and have an arrow in the breakpoint margin)?
No, the same thing happens even if run a newly created project to which I've added no code. It's probably a bug. I have 2005 Express Edition.
 
Here is a question: are you using VB with the application framework enabled (it is under Project/Properties in the menu)? For some reason, I think that this might have something to do with it.
 
marble_eater said:
Here is a question: are you using VB with the application framework enabled (it is under Project/Properties in the menu)? For some reason, I think that this might have something to do with it.
Yes I am, and you're right, when I deselect that it works OK. So I suppose that's my choice - either I turn that off or I continue dealing with this as I have been doing before.
 
Back
Top