简体   繁体   中英

VS2015: Expression Evaluated But Variable Not Available

Running into an odd situation debugging an MVC6 app.

In the Startup::Configure() method I have a break set on the following code:

var junk = app.ApplicationServices.GetRequiredService<IOptions<AntiforgeryOptions>>().Value.CookieName;

I'm trying to look up the app-specific antiforgery cookie name.

The expression evaluates...but when I try to look at the value of 'junk' in the Watch window I get an error message to the effect that 'junk' does not exist in the current context.

Hovering the mouse over 'junk' in the code window shows... nothing. It's as if the variable doesn't exist.

OTOH, if I evaluate the exact same code in the watch window, the name of the cookie is displayed as the resulting value.

I added a few lines after the initial call:

var junkLen = junk.Length;
var junk2 = junk;

These execute without any problems, either, but you can't examine them in the Watch window because they don't exist :).

I've never seen anything like this. Any thoughts on what's going on?

Turns out this is a recently-reported bug in the recently-released VS 2015 Update 2 which has been fixed by an even more recently released patch from Microsoft. Which you can find at http://go.microsoft.com/fwlink/?LinkID=785969&clcid=0x409 .

The discussion including the patch reference is at https://connect.microsoft.com/VisualStudio/feedback/details/1038150/visual-studio-2015-debugger-doesnt-recognize-a-variable

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM