7

I've been working in C# and VB.NET a lot lately, and the other night I noticed this strange behavior when running some through a debugger and trying to look at the contents of a Dictionary object. I'm fairly certain I've looked through a Dictionary in C# before and saw its contents, but now what I'm seeing is:

C# Dictionary in the debugger

Poking around in those sub parts, like the keys and values, doesn't show what's in the dictionary, just take me around in a loop to this same debugger window. I can't look at my values anywhere here.

Where as VB.NET looks fine:

VB.NET Dictionary in the debugger

Any idea why C# is different? Is there a setting or something I have off?

cost
  • 4,420
  • 8
  • 48
  • 80
  • 3
    C# and VB.Net are very similar as far as the debugger is concerned. They both use IL as their intermediate language. The difference must be because you clicked on something different... I just tried it from C# and I can expand the dictionary and see all its items fine. The underlying dictionary is EXACTLY THE SAME CODE for C# or VB - they both use the same .Net libraries. – Matthew Watson Feb 18 '13 at 18:25
  • @MatthewWatson Thus the reason for my great confusion, because the code is the same in both the c# and vb.net projects. Same kind of dictionary, even. – cost Feb 18 '13 at 18:28
  • 1
    Here - http://stackoverflow.com/questions/2789580/why-is-the-dictionary-debug-visualizer-less-useful-in-visual-studio-2010-for-sil Although not directly related, I guess it will give you hint on this. – shahkalpesh Feb 18 '13 at 18:35
  • @Matthew Watson: That is not true at all. VB.NET debugger and C# debugger interpret the System.Diagnostic attributes differently, e.g. the C# bug of always displaying hidden members if the source comes from the same solution was only recently introduced into VB.NET (can't tell why they didn't fix it in C#). VB.NET also had a differentiation between often and less used members, so normally a short list like a summary was displayed, and when needed one could switch to the full list (just a 2nd tab in the mouse-over). Only now with recent versions they are levelling the differences out a bit. – Christoph May 28 '19 at 12:48
  • Since this question is still getting some attention, I think I fixed this simply by restarting Visual Studio. – cost May 28 '19 at 16:29
  • @Christoph Well it seems that this was just a bug that required the OP to restart Visual Studio... – Matthew Watson May 29 '19 at 08:49

1 Answers1

3

Somehow you're being shown the "Raw View -> Non-Public members" window. However, the list of numerically-indexed values should be accessible if you scroll down in this window to the next-to-last row, "values". Can you post a screenshot showing the expanded "keys" window?

Uncheck Tools -> Options -> Debugging -> General, 4th option from last: "Show raw structure of objects in variable windows". (Thanks should also go to https://stackoverflow.com/a/13422426/2236012 for sharing this settings path.)

Community
  • 1
  • 1
C.B.
  • 666
  • 3
  • 18
  • I posted in the question that opening up the keys and values window didn't actually display anything worthwhile. It just wound up being a loop back to the same window. I don't recall exactly what it showed, this problem was a while ago, but it wasn't giving me any of my values like I wanted. I don't know why. – cost Jun 11 '13 at 17:10
  • Ok, i must've "optimized" over that sentence, probably because i was also looking at the screenshots when i read it... :"> Anyway, found a way to repro your problem, and i think my updated answer will solve the issue. – C.B. Jun 12 '13 at 11:59