in

Platinum Bay

Peace, Love, Team System, and Community

This Blog

Syndication


.NETicated

Visual Studio: Immediate Window Debugging

I love debugger visualizers. For the most part, they work great. But debugger visualizers aren't much help when trying to examine arrays of objects or non-generic collections. In the example below,

In this particular instance, I wanted to see the names, types and values for each item in the command1.Parameters collection. Similarly, the Locals window didn't help either.

Here is where the Immediate Window comes to the rescue. I can get the value I want my using the following syntax:

? command1.Parameters("@sqlPopulate").Value

The question mark at the beginning tells the Immediate Window to output the results, as in the following example which will get the name and value of parameter 2:

? command1.Parameters(2).Value
5 {Integer}
    Integer: 5 {Integer}
? command1.Parameters(2).ParameterName
"@PageSize"

The beauty, as you can see, is that I can use full .NET syntax to work with the objects in scope at the current point of execution, and you get IntelliSense to boot.

Have fun!

 

Published Sep 02 2007, 04:04 PM by Steve
Filed under: ,

Comments

September 13, 2007 5:52 PM

That's super if you know the name of the key you're looking for.  It's highly frustrating if you're attempting to peer into code that's not your own.

Andrew
 

September 28, 2007 9:24 AM

Thank you, this is very helpful.  

But does anyone understand why the C# debugger seems to let you look into these  type of objects seamlessly?

I've been thinking my VB debugger was just broken!

Al
 

January 16, 2008 9:57 PM

C# debugger works great due to CLR, I guess. CLR knows everything about your program and data structures, right?

Sooho
 

Leave a Comment

(required )  
(optional )
(required )  
Add

About Steve

Steve Andrews is a Team System MVP and INETA Speaker, and has been working as a developer for more than 9 years. During this time, he has designed and developed applications in such widely varying areas as trust accounting, medical information management, supply chain management, and retail systems. Steve is also an MCP, ICSOO, Speaker Liaison for the Philly .NET User Group, and community fanatic.
Powered by Community Server (Commercial Edition), by Telligent Systems
© Platinum Bay | Some Rights Reserved Creative Commons License

Disclaimer: The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion. Feel free to challenge me, disagree with me, or tell me I'm completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or annonymous comments) - so keep it polite, please.