Search
Tuesday, October 16, 2018 ..:: Home ::.. Register  Login
   Calendar  
     
  
   Search  
     
  
   Blogroll  
     
  
   Disclosure  
All blog entries are the opinions of the author and do not necessarily reflect the opinions of their employer. All the code presented is for explanation and demonstration purposes only. Any damages incurred to your site and/or data are not the responsibility of the author. Every effort is taken to ensure the code properly compiles, however sometimes there are some hiccups and you might be required to do your own debugging.
     
  
   TechTidBits (Blog)  

Visual Studio Debugger Visualizers (Take Two)

Sep 3

Written by:
Friday, September 03, 2010 9:53 PM  RssIcon

Unhandled exception with Debugger VisualizersDo you have some Visual Studio debugger visualizers that worked in VS 2008 but don't work in 2010?  Are you getting an unhandled exception that cannot cast your custom object to an ImageDebuggerVisualizer object? I (hopefully) have the quick fix for you!

Unhandled exception with Debugger VisualizersWhen I upgraded to Visual Studio 2010, I forgot about my custom image Debugger Visualizer.  DOH!  Well, last week, I remembered and when I tried to "install" it (copy the assembly) I was met with a nasty, scary and unfriendly uncaught exception!  DOH!  Oh man!  After 10-15 minutes of trying to figure it out, I realized this was going to take some more sleuthing than what I could afford that day.

Fast forward to tonight and I have more time.  I started with last year's blog post and code I created last October (Visual Studio Debugger Visualizers are VERY cool! You gotta check this out!), fixed the problems with where the DebuggerVisualizer assembly needs to be copied to.

Normally to create/edit your custom DebuggerVisualizers you need to run VS as administrator privs.  BUT!  With VS 2010, on Windows 7, you can actually copy the assembly you need to

C:\Users\USERNAME\Documents\Visual Studio 2010\Visualizers

In fact, in the sample solution I have here, there's a Build Event which will automagically copy the compiled assembly to the correct directory for immediate use!  Very cool eh?  I encourage you to check it out!

The ONLY down side to doing it this way, is if you're sharing your machine with other people, either they ALSO have to copy the DLL to their Users directories, OR, you can alternatively do what VS 2008 used, and copy the assembly to the more global referenced directory. On x64 machines (note the x86 in the directory name, VS is still a 32bit application) the assembly goes in

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Packages\Debugger\Visualizers

It's COMPLETELY up to you where you want to put the assembly DLL. If you put it in the Users subdirs, then you get away without having to start VS as Administrator, but you can't share it.  If you put it in the Program Files sub directories, you have to have gain write privs but everyone can use it.  Your call.  Me?  I'm using the Users directory cause it's MUCH easier to update and deploy it, and I'm lucky enough to be the only geek on my machine (phew! LOL).

Next, once I loaded up my VS 2008 solution and upgraded it to VS 2010, then ran it, BOOM!  I got the exception shown below.  As you can see, to paraphrase (and help others googling for it) Unhandled exception has occurred in a component in your application...Unable to cast object of type 'blah.blah.blah.ImageDebuggerVisualizer' to 'Microsoft.VisualStudio.DebuggerVisualizers.DialogDebuggerVisualizer'.

Unhandled exception with Debugger Visualizers

There were two problems I had to fix.  GREAT!  Compound problems are the worst aren't they?  When you fix something you're still left with it not working and you never really quite know if the FIRST thing you did is helping or hindering you?

Anyways, the first bug had to do with the placement of the VisualizerDebugger assembly DLL.  But from above, you now know where it goes.  The next bug had to do with the referenced DebuggerVisualizers assembly.  DOH!  I completely forgot about that, and never even THOUGHT that might be causing me a problem.  But a couple of blogs eluded to this being the problem, but a blog by Andrew Smith, Josh Smith and Karl Shifflett confirmed it.  If you're seeing this exception, check out the DebuggerVisualizers Version, if it's 9, you need to update it!

Solution Explorer showing assembly version number

hhhhmmmm Next question is where IS the updated DebuggerVisualizers assembly?  Check out this directory, C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0.

Adding the right assembly reference

 Once you do that, run the test project, it has a Debugger.Break() so you can quick test it out.  If you see the magnifying glass, click it and you SHOULD see your custom debugger visualizer, just like mine!  LOL

VisualizerDebugger working again

Now that you know how to fix your custom debugger visualizers, it's time to grab a coffee and get coding! 

 

Resources:

Source Code: http://www.pchenry.com:8080/svn/blog/trunk/2010/ImageDebuggerVisualizer

PCHenry.com: Visual Studio Debugger Visualizers are VERY cool! You gotta check this out!

The Code Project: Mole For Visual Studio - With Editing - Visualize All Project Types by Andrew Smith, Josh Smith and Karl Shifflett

Tags:
Categories:
Location: Blogs Parent Separator TechTidBits

4 comment(s) so far...


Gravatar

Re: Visual Studio Debugger Visualizers (Take Two)

That's what I was aiming for! Thank you Nerevar for leaving a comment. Unfortunately I haven't had a lot of time lately to blog, but have been wondering if it's worth the effort I put in? And people's comments like this DO help push me to continue. For that, thank you very much, I always appreciate people's comments. Thanks again and have a good week!

By Peter Henry on   Wednesday, November 07, 2012 10:25 AM
Gravatar

Re: Visual Studio Debugger Visualizers (Take Two)

OH SNAP!!!!!!!!! Some how, some way I lost Nerevar's comment? DOH!AARRRRGGGGHHHHH Thankfully I have at least the text. Sorry about that Nerevar, but your thoughts are not lost!
----------------------
Re: Visual Studio Debugger Visualizers (Take Two)

Thank you for not being lazy and writing on your experience. It saves a lot of fellow programmers' time.

By Anonymous, on 11/7/2012.

By Peter Henry on   Wednesday, November 07, 2012 10:26 AM
Gravatar

Re: Visual Studio Debugger Visualizers (Take Two)

You saved me! I spent quite a bit of time on this before finding this web page. Thanks for taking the time to write this up. BTW: This also applies when upgrading to VS 2012.

By Gene S on   Wednesday, April 17, 2013 11:00 AM
Gravatar

Re: Visual Studio Debugger Visualizers (Take Two)

My pleasure Gene! Glad I could help! And thanks for posting the tip about VS2012! Many thanks and have a good weekend!

By Peter Henry on   Sunday, April 21, 2013 7:37 PM

Your name:
Gravatar Preview
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Add Comment   Cancel 
     
  
Copyright 1999-2012 by PCHenry.com   Terms Of Use  Privacy Statement