C# Debugging Improvements for VS 2008 SP1- Part 1


Over the past few months I have been busy closing VS 2008 and working on some fixes for SP1. We have enabled some key debugging scenarios in C# in VS 2008 SP1, they include support for 

  1. Range Variables in Queries &

  2. Anonymous Types

  3. Generic Type arguments

Covering all of them was making the post long so i am going to discuss Range variables this time and continue on with the other 2 in the next post.

Range variables

Range variables are the variables defined and used in a query. Currently they have a limitation in that they are not recognized as "true" local variables when stopped/stepping though a query. And since queries are one of the newest constructs in C#, are a prime candidate for SP1.

Range variables cannot currently be inspected in the watch window or in data tips(hover over them), quick watch and immediate. They can only be seen in the locals window,  but the display shows the internal transparent identifier created for the query. This leaves the variable of interest to the user nested and difficult to understand and use.  This happens as long as the user adds

1. A second from,

int[] ints = new int[] { 1, 2, 3, 45, 56 };

var q = from i in ints
            from k in ints
            where i > k      //add BP here
            select i + k;


2. A join or


3. A let clause to their query,


Seeing these simple examples it is not hard to imagine the debugging state when stopped in queries that use many of these in combination.


Here "Hover over" does not work, can't add anything to watch, the transparent identifier gets larger and the lvl of nesting makes it very hard to find the range variables your looking for.

SP1 Changes

All of these issues are now fixed in SP1 and the user has the full set of debugging tools for him to help inspect and evaluate the current state when stopped at a break-point. using the same example



In concluding this article, As always I am very interested in

  1. Any others pain points you have discovered while debugging or

  2. Things are are hard to debug.

  3. Things that would be nice to inspect etc.

Looking forward to your feedback. Cheers

kick it on DotNetKicks.com

Comments (17)

  1. Dave says:

    You mention a VS2008 SP1, and yet the product is not that long released.  It took what felt like years to get to a SP1 for VS2005 – what is the SP1 released schedule like for VS2008?

  2. Sree_C says:

    VS2005 also took like 3+ years to get done, compared to the 18 month cycle for VS2008. And Yes it’s a part of the more agile release cycle that VS will be following going forward. I don’t have a good date to tell as to when its done, but it might be sometime this year. Check out Soma’s blog he might have more on this soon.

  3. Eric says:

    This just seems cruel – discussing the cool features of an upcoming service patch and then giving an 11 month (maybe!) window of when we will get it…

  4. Oren Novotny says:

    How about allowing Edit-n-Continue in anonymous methods? 🙂

  5. I second edit and continue in methods containing anonymous delegates (and of course in the anonymous delegates themselves too).

    Also, it’s not possible to use lambda functions in the immediate window or any of the other debugger windows.  This would be extremely handy – for example, LINQ queries are very well suited to drilling down through data structures to find sources of trouble.

    I’d be extremely pleased to find support for debug-time LINQ and other code-generation features (write a method just to analyze the state as it is now).  If access to local variables complicates matters, I would much prefer being able to write a LINQ query and/or debug-time dynamic method which can only access member variables than not be able to use these features at all.

  6. I just read an interesting post about debugging enhancement for Visual Studio 2008 SP1 . Right, the post

  7. Sree_C says:

    Interesting… i can totally see how lambdas and queries can be used to inspect interesting elements of a big data structure.

    Adding these features has been challenging mainly due to the fact that we can’t generate types at runtime and the lambda is rewritten to a display class. We could restrict the lambda to variables that are already hoisted but that complicates the user model.  

    I am personally looking forward to implement many of these for VS10,  Though there are a few things that need to be figured out.

    Enc is another area we will be revisting for VS10

  8. You’ve been kicked (a good thing) – Trackback from DotNetKicks.com

  9. Kornel Lehocz says:

    Please fix debugging of managed/native mixed dll-s. I don’t know if this is a general bug or if it only doesn’t work here. But it doesn’t work at all. Breakpoints set in native code are just ignored. (VS 2008 Pro, Windows XP SP2)

    And please also improve C++ debugging.

  10. Kornel Lehocz says:

    I just found the Enable unmanaged code debugging option. 🙂 So ignore my last silly post.

  11. Welcome to the fortieth issue of Community Convergence. This week we have two new releases of note: We

  12. MihaM says:

    I just read an interesting post about debugging enhancement for Visual Studio 2008 SP1 . Right, the post

  13. Zunanji viri says:

    I just read an interesting post about debugging enhancement for Visual Studio 2008 SP1 . Right, the post

  14. gOODiDEA says:

    .NET: C#DebuggingImprovementsforVS2008SP1-Part1


  15. Art Fenerty says:

    Ive found c++ debugging quite often wrong. The debugger is showing the wrong address and variable state. For example the watch window will show.

    bool  m_Animate  true

    when breakpointed on the last line..

    m_Animate = false;

    bool test = m_Animate

     test will show false, debugger will be pointing several bytes ahead in adress and report m_Animate is true.. havent yet tracked it down..


  16. Russell Hind says:

    As requested above, we really could use edit/continue debugging of anonymous delegates.  Currently we don’t use anonymous delegates because some of our simulation/test runs can take hours and we can make heavy use of edit/continue which is not supported.

    Edit/continue of generics would also be very useful and we’re just moving to Vista 64 and miss edit/continue on this as well.

    It would be useful to have a standard feature set across all platforms and language features.



  17. On Monday, Chris , Bob , and I wrapped up the latest edition of the Northeast Roadshow in Waltham. 

Skip to main content