Help getting ExpressionTree visualizer to work in VS2010

39 views
Skip to first unread message

Sacha Barber

unread,
Apr 17, 2012, 4:39:05 AM4/17/12
to wpf-di...@googlegroups.com

I am having trouble getting the old VS2008 ExpressionTree deubgger visualizer sample which is available here : http://code.msdn.microsoft.com/Visual-Studio-2008-C-d295cdba

Working with VS2010.

I understand that sample was built for an older version of .NET, and as such needs to be recompiled using the latest VS2010 DebuggerVisualizers.dll.

So here is what I have done

  1. Downloaded VS2008 samples from link above : http://code.msdn.microsoft.com/Visual-Studio-2008-C-d295cdba
  2. Opened project in VS2010
  3. Changed the projects to target .NET4.0
  4. Changed the references to point to this location for the DebuggerVisualizers.dll : C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.VisualStudio.DebuggerVisualizers.dll
  5. Built the projects, checked that I can actually visualize an expression tree. All works fine in modified standalone project from samples
  6. Copied the ExpressionTreeVisualizer.dll to the following locations

    ...\Documents\Visual Studio 2010\Visualizers 

    ...\Program Files\Microsoft Visual Studio 10.0\Common7\Packages\Debugger\Visualizers

But I can't see the debugger visualizer in VS2010 at all.

Anyone know what I am doing wrong


--
Sacha Barber
sacha....@gmail.com

karl shifflett

unread,
Apr 17, 2012, 8:34:08 AM4/17/12
to wpf-di...@googlegroups.com
Sacha,

When you say you can't see it, what does that mean?

Have a look at the Assembly.cs file.  Do you see the visualizer attributes there?  Your visualizer will register to visualize only those types and you will be able to "see" the visualizer in the debugger data tip when your cursor is hovering over those types.

Does this help, or did you already know this?

Cheers,

Karl

Sacha Barber

unread,
Apr 17, 2012, 9:17:20 AM4/17/12
to wpf-di...@googlegroups.com
I mean I do not even see a debugger data tip, and yes it has the correct Assembly attributes, which are as follows:

[assembly: DebuggerVisualizer(typeof(ExpressionTreeVisualizer), typeof(ExpressionTreeVisualizerObjectSource), Target = typeof(Expression), Description = "Expression Tree Visualizer")]


I have attached the code Karl.

I would be grateful if you could let me know what is up exactly, as I think it should work. In fact it did work in VS2008 (when it was written, its one of the Microsoft samples from VS2008, which I converted to VS2010)...It should work, as its an official MSFT dermo one

I have copied the resulting dll to : C:\Users\barbers\Documents\Visual Studio 2010\Visualizers (which is of course the path on my box)


To test it you can create the following Console app


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Expression<Func<Program, bool>> f = (x) => x.GetType().Equals(typeof(Program));

            int[] stuff = new int[] { 1, 2, 3, 4, 5, 6, 6 };

            var data = from x in stuff where x > 1 select x;


            Console.ReadLine();
        
        }

    }
}



Any ideas man? Really would be great to get it to work




--
Sacha Barber
sacha....@gmail.com
ExpressionTreeVisualizer.zip

Karl Shifflett

unread,
Apr 17, 2012, 9:23:44 AM4/17/12
to wpf-di...@googlegroups.com
Sacha,

Let me download the attachment and give it a go on my box when I get off work tonight.

Glad to help,

Cheers,

Karl

Sacha Barber

unread,
Apr 17, 2012, 9:33:25 AM4/17/12
to wpf-di...@googlegroups.com
That would be ace Karl.


I also raised this as question on stackoverflow which gives you more information, and the steps I took to try and get it to work


Thanks K-Dawg, I figured if anyone would know about Debugger Visualizers it would be you
--
Sacha Barber
sacha....@gmail.com

Sacha Barber

unread,
Apr 17, 2012, 10:08:42 AM4/17/12
to wpf-di...@googlegroups.com
Karl here is some more detail


If I take a direct reference on the DebuggerVisualizer dll (which I should not have to), and also take a reference on Microsoft.VisualStudio.DebuggerVisualizers.dll
and then do this


 static void Main(string[] args)
        {
            Expression<Func<Program, bool>> f = (x) => x.GetType().Equals(typeof(Program));


            VisualizerDevelopmentHost host = new VisualizerDevelopmentHost(f,
                                                 typeof(ExpressionTreeVisualizer),
                                                 typeof(ExpressionTreeVisualizerObjectSource));
            host.ShowVisualizer();   

            Console.ReadLine();
        }


I see this Visualizer working correctly. So I know it works, there just seems to be some registration issue for the Visualizer (do I need to restart my machine after copying the debugger visualizer to my "C:\Users\barbers\Documents\Visual Studio 2010\Visualizers" folder?


This could be a read herring but these days within VS2010 there is a new "DebugView" which  I think applies to ExpressionTrees in VS2010, see this blog : http://blogs.msdn.com/b/csharpfaq/archive/2009/11/19/debugging-expression-trees-in-visual-studio-2010.aspx

Perhaps this is overriding the debugger visualizer behaviour and preventing it from being shown. 
--
Sacha Barber
sacha....@gmail.com
Reply all
Reply to author
Forward
0 new messages