views:

439

answers:

1

Hi folks,

I have created a debugger visualizer in VS2008. There are two classes i've made, in the same .dll :-

  • BinaryDataDebuggerVisualizer
  • ImageDebuggerVisualizer

The image one works fine (eg. the magnify glass appears in debug mode) but not for the byte[] one (BinaryDataDV). What my visualizer does is display the binary data as an image in a modal window (if the data is a legit image). I compiled to code in Release mode, then dropped the .dll into C:\Users\\Documents\Visual Studio 2008\Visualizers

this is the code that i used to 'define' the vis...

using

System;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using Microsoft.VisualStudio.DebuggerVisualizers;
using Foo.DebuggerVisualizers;  

[assembly: DebuggerVisualizer(
    typeof (BinaryDataDebuggerVisualizer),
    typeof (VisualizerObjectSource),
    Target = typeof (byte[]),
    Description = "Binary Data to Image Visualizer")]

namespace Foo.DebuggerVisualizers
{
    public class BinaryDataDebuggerVisualizer : DialogDebuggerVisualizer
    {
        protected override void Show(IDialogVisualizerService windowService,
           IVisualizerObjectProvider objectProvider)
        {
            ... my code in here
        }
     }
}

I've made a unit test in the debugger visualizer solution, which fires up and test the code .. which it correctly shows a legit (and also illegal) image files. so i believe the code is ok.

When i'm in my real solution, this is what i'm doing (where i expect the magnify glass to show, when i'm hovering over the variable in debug mode).

byte[] data = File.ReadAllBytes("Chick.jpg");

then i hover over the variable data when i've paused the code while debugging, on that line (using a breakpoint).

No hourglass :(

anyone have any ideas to what is wrong?

+4  A: 

Unfortunately this is not possible. There is a limitation in the Debugger Visualizer framework that prevents them from functioning on array types or object.

http://msdn.microsoft.com/en-us/library/e2zc529c.aspx

Quote from the page: "You can write a custom visualizer for an object of any managed class except for Object or Array"

JaredPar
Thanks heaps for the answer. Wowzer! out of all the viz's i tried to do, it was one of them that wasn't supported! so lol :P thanks heaps JaredPar for the answer!
Pure.Krome
The authors of the visualizer 'Mole' recommend working around this by attaching the visualizer to 'WeakReference', and then newing a WeakReference for the object. See http://joshsmithonwpf.wordpress.com/2008/01/
Will Dean