A fix to the awesome Snoop utility, RRS feed

  • Question

  • Hi guys,
    The snoop utility is great, it really is. However, there is a huge problem with it. It crashes the host application once you try to snoop at an element nested about 65 levels deep.
    The reason is simple - nesting is limited to 255 levels deep. The limit is hardcoded and cannot be surpassed. I guess it is for the same reason as the nesting of true Win32 window handles is limited to about 50. This blog explains it for the win32 world.
    Anyway, 65 is not 255, right? But Snoop displays a TreeView control in the right pane, which visual template is such that nesting about 65 levels hits the 255 limit. Once the limit is hit, Snoop crashes, bringing with it the host application.

    I do not know if the Snoop author, Mr Pete Blois, has already fixed this issue. I took the liberty to slightly modify the Snoop source to avoid the crash. The fix is to change the root item of the TreeView control when needed. If the fix is still relevant, I would like to send the modified source to the author, so that he reviews it and merges it to his source, provided, of course, he agrees with it. This way others will benefit from it.
    The only problem is that Mr. Pete Blois' contact info is not published on the web, though I think he is a Microsoft employee.
    Any thoughts, folks?

    • Changed type Markell Wednesday, November 19, 2008 9:31 AM
    • Changed type Markell Wednesday, November 19, 2008 9:31 AM
    Sunday, October 26, 2008 9:29 AM

All replies

  • No, but I sure appreciate Pete for having created Snoop and your sharing of your findings.
    Monday, October 27, 2008 6:56 PM
  • Hmm...
    Seems, like either no one was hit by the limit or every one just fixed it in their local copies of snoop :-).

    Tuesday, November 11, 2008 5:35 PM
  • Anyway, has anyone used the new version of Snoop? Because in addition to the old deep recursion bug it has two regression bugs, which diminish its usefulness greatly:
    1. It fails to update property values in the snooped application. Adding the following line in the PropertyInformation constructor fixed the issue for me:
    binding.Mode = property.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay;
    2. It fails to retreat back from the delved in context. It looks like there was last minute commit in PropertyInspector.xaml.cs and nobody cared to verify it. The fix is easy, but nevertheless required.

    I am wondering whether I am the only one who is actually using Snoop and have noticed this stuff or there is “the right” version out there and everyone is using it instead?

    Wednesday, November 19, 2008 9:29 AM
  • Thanks for posting the fix to issue #1; I tried it, but it didn't seem to work for me, and in fact the TextBox in snoop where you enter the new property value (still) won't accept the text. Here is where I added your line (it is bolded). Any ideas?

    public PropertyInformation(object target, PropertyDescriptor property, string displayName) {

    this.target = target;

    this.property = property;

    this.displayName = displayName;

    Binding binding;

    DependencyProperty dp = this.DependencyProperty;

    if (dp != null) {

    binding = new Binding();

    binding.Path = new PropertyPath("(0)", new object[] { dp });



    binding = new Binding(property.DisplayName);

    binding.Source = target;

    binding.Mode = property.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay;

    try {

    BindingOperations.SetBinding(this, PropertyInformation.ValueProperty, binding);

    } catch (Exception) { }


    this.isRunning = true;


    Wednesday, December 10, 2008 5:06 PM
  • I can send you the full source after my fixes.
    What's your email?
    Thursday, February 19, 2009 10:15 AM
  • Hi Markell, I have the same problem with Snoop not setting properties (In my case SnapsToDevicePixels). You fix makes sense but shows no effect. It would be nice if you could send me your fixed source. My mail is Martin@ (I don't like spam) http://rauscheronline.de Thank you!
    Friday, April 3, 2009 4:17 PM
  • Markell,

    I would love the full source with fixes as well ... if you could email it to coryplotts@ (I don't like spam either) gmail.com.

    Thanks in advance,
    Friday, April 3, 2009 11:08 PM
  • Markell,

    Pete's email is at the end of the MIX 09 session that he did this year (http://videos.visitmix.com/MIX09/C27M).

    His blog is: http://blois.us/blog/

    Let us know if you get the fixes in or receive word back from Pete,

    I have found an issue and am working on fix for interop scenarios. (We're a Windows Forms application that hosts WPF. Snoop currently relies on the Application object to get at the Dispatcher ... I'll reply back here too, when I get a fix.)
    Saturday, April 4, 2009 2:22 PM
  • Done.
    Saturday, April 4, 2009 8:50 PM
  • Done.
    Saturday, April 4, 2009 8:51 PM
  • Cory,

    Unfortunately, the blog does not seem to have an entry on Snoop and it would be somewhat impolite to intrude in other topics. To tell the truth, I gave up on submitting the fixes back to Pete.
    It is just too troublesome...
    Saturday, April 4, 2009 9:01 PM
  • I have just blogged about my WPF interop fix.

    Basically, you need to change the Equeue method of the DelayedCall class:
    public void Enqueue()
        if (!this.queued)
            this.queued = true;
            Dispatcher dispatcher = null;
            if (Application.Current == null)
                dispatcher = Dispatcher.CurrentDispatcher;
                dispatcher = Application.Current.Dispatcher;
                new DispatcherOperationCallback(this.Process),

    And you need to change the Inspect method of the SnoopUI class:
    public void Inspect(object target)
        this.rootObject = target;
        this.CurrentSelection = this.root;
        if (Application.Current != null)
            this.Owner = Application.Current.MainWindow;

    I hope this helps someone. I think it is awesome! :)
    • Edited by Cory Plotts Monday, April 13, 2009 4:16 PM Weird. For some reason, making an edit screws up your code snippets ...
    Saturday, April 4, 2009 10:57 PM
  • Me too.
    Sunday, April 5, 2009 5:42 AM
  • Just found and fixed the remaining keyboard issue that existed in WPF interop scenarios. Check out my blog post for more details (and additional fixes), but basically, you need to call ElementHost.EnableModelessKeyboardInterop in the Inspect method of the SnoopUI class.
    Monday, April 13, 2009 4:10 PM
  • "Thanks for posting the fix to issue #1; I tried it, but it didn't seem to work for me, and in fact the TextBox in snoop where you enter the new property value (still) won't accept the text. Here is where I added your line (it is bolded). Any ideas?"

    I noticed that if you have Snoop installed while attempting to run it from inside visual studio then it references libraries in the GAC. This gives the impression that you're running the modified version, but you're actually running the installed version. Uninstalling Snoop remedied this situation and the property bindings worked correctly.
    Friday, July 24, 2009 5:01 PM
  • RagingChikn , sorry but I did not understand your reply at all.

    BTW, I blogged about the issue here . That post also contains the source code of my fixes.
    Friday, July 24, 2009 7:45 PM
  • I have made and integrated a whole bunch of features into my version of Snoop ... most notably, the ability to Snoop 64-bit applications without having to recompile the target application as an x86 application ... by creating a 64-bit version of Snoop.

    Check out http://www.cplotts.com/2009/12/08/snoop-now-with-64-bit-support-and-more/ for more info ... and for the source code and binaries.
    Tuesday, December 8, 2009 6:15 PM