Nick's .NET Travels

Continually looking for the yellow brick road so I can catch me a wizard....

VB.NET Meets the DebuggerDisplay Attribute in VS2008

One of the most annoying things I find about working with the Guid class is that in order to see what the value is you have to go into a watch window and query myguid.tostring(), this doesn't sound like too much work but if you are used to relying on datatips it can quickly be quite annoying.  For a while I've thought about writing a debugger visualiser or type proxy to add my own datatip for the Guid class and today I got off my backside and did it.....

The steps for doing this are relatively simple:

  • New Project (VB.NET or C#, doesn't really matter - at this stage anyhow)
  • Add Reference: C:\Program Files\Microsoft Visual Studio 8.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.DebuggerVisualizers.dll
  • Add the following attribute to any code file (most likely assemblyinfo.vb)
  • Imports Microsoft.VisualStudio.DebuggerVisualizers
    <Assembly: DebuggerDisplay("Guid {ToString()}", Target:=GetType(Guid))>

Now build this assembly and drop it into Documents\Visual Studio 2005\Visualizers.  Open up a new instance of Visual Studio, open an existing or new project that uses the Guid class.  Run the project with a breakpoint set so you have an instance of a Guid that you can mouse over:

image

And hey presto you have a useful datatip for the Guid class...... WRONG.  What you see here is the datatip in Visual Studio 2008 for VB.NET.  In Visual Studio 2005 this only seems to work properly for C#, VB.NET doesn't seem to properly support the DebuggerDisplay attribute (Note you can still follow the above steps in either VB.NET or C# to create the implementing assembly, it's just the executing code that needs to be in C# in VS2005). 

  • pak web hosting

    12/20/2010 2:09:04 AM |

    We are also very happy to now offer web hosting services, regardless of whether or not you want us to build you a website;
    There’s no need to go scouring the net for a great web hosting service to compliment your new site…
    GFsoul does web hosting and takes care of all the important details like domain name registration.
    Our design and hosting services perfectly compliment each other; we are offering customers true “one-stop shopping” experience, and at extremely affordable prices. You won’t find customized web design and hosting at these amazingly low prices anywhere buy here.
    Our web hosting services features all of the same appointments that other (better known) web hosting services can offer you, but with lots of great tech support, customization and a lower overall cost.

Comments are closed