Snoop: Now with 64-bit Support and More

The other day I was rebuilding an application such that it would specifically target the x86 platform … solely because I wanted to Snoop it.

I’ve done this many, many times because it is the only way I’ve been able to Snoop applications on my Windows 7 64-bit operating system. And, I thought, “Boy, this is stupid. I should be able to build a 64-bit version of Snoop such that I don’t have to do this anymore.”

And that is exactly what I did.

Now … presenting Snoop 32-bit!


And Snoop 64-bit!


Here are the binaries for the 32-bit version and here are the binaries for the 64-bit version.

(The binaries are now (see posts: 1, 2) up on CodePlex. Please go download it from there as those binaries will contain the latest and greatest bits.)

It was rather a simple matter really. I just needed to change all the project configurations so that they targeted the x64 platform … for the x64 version of Snoop … and all the project configurations so that they targeted the x86 platform … for the x86 version of Snoop.

This was so easy and worked so nicely … that I searched the internet to see if anyone had done this already … and I found Dan Hanan’s nice post on the matter.

The problem, though, was that he did it for original version of Snoop … and not the nicely styled and improved version that Pete Blois currently is making available since property editing was originally (still?) broken in that version. However, he also had several nice usability features that I was drooling over and wanted for my very own. 😀 And I, of course, have already fixed the property editing issue in my version (see previous posts: 1, 2) with a little help from Mark Kharitonov (see this forum post for more info on that).

So, I emailed him, got his permission to integrate those changes, and promptly did so. I also added a few improvements myself.

The Improvements

Here is what has been improved (over and above Pete Blois’ current version):

Improvement Originator
Handles WPF interop scenarios (both Windows Forms hosting WPF and WPF hosting Windows Forms). Cory Plotts
Fixed the ability to edit properties. Mark Kharitonov
Modified Snoop so that it can handle visual trees that have nesting greater than 255 levels deep. Mark Kharitonov
Modified the project configurations so that you can build a 32-bit version and a 64-bit version. This is what the blog post is all about! Ha! Cory Plotts
Dan Hanan
Turned off the showing of properties at their default value (by untoggling the Show Defaults toggle button). Dan Hanan
Turned auto refresh off in the AppChooser. Snoop was previously polling every 20 seconds for new applications. Dan Hanan
Added a checkbox to turn auto refresh back on (if you so desire). Dan Hanan
Added a label to the AppChooser to indicate 32-bit versus 64-bit. Dan Hanan
Added a wait cursor when the AppChooser is busy iterating over the applications to possibly Snoop. Dan Hanan
Added the capability to bring the selected tree view item into view. Dan Hanan
Added the capability to filter properties based on predefined sets of properties. Dan Hanan
Added the ability to pop the target (after a delve) with the back button on the mouse. Dan Hanan
Modified the selected item in the tree view to be a light blue even when it doesn’t have focus. Dan Hanan
Added the ability to pop the target (after a delve) with the alt-left arrow keyboard sequence. Cory Plotts
Added the ability to remember window position, size, and the maximized/minimized/normal state for all three Snoop windows. Cory Plotts
Removed the filtering of ‘devenv’ out from the list of applications that you can Snoop. Cory Plotts
Modified the project configurations so that it never builds the installer. I just copy the Snoop executable and the ManagedInjector dll from place to place. Don’t know if this an improvement. 🙂 Cory Plotts
Fixed the x86 installer and created an installer for x64. Snoop is no longer being added to the GAC and the assemblies are thus no longer strong named. The installers for both platforms should now work. Cory Plotts
Integrated Anvaka’s great suggestion below (see the comments). That is, I moved the long label that tells a user how to ctrl-shift click on the application being Snoop(ed) (to a tool tip on the tree view) … and replaced it with a label that tells the user what the immediate following hyperlink is … that is, the Keyboard.FocusedElement. Also added another label and hyperlink for the current selection’s focus scope. Andrei Kashcha (Anvaka)

I chose not to integrate a couple of Dan Hanan’s changes. First, I did not integrate the ‘indexer delve’. Well, actually I did, but then noticed that Pete Blois’ new version already allowed you to delve into items in a collection … and so I backed it out.

Second, I did not integrate the ‘use 2nd monitor if present’ feature. I liked that feature but thought that I would try to improve upon it by remembering the position and size of all the windows … regardless of the number of monitors. So, with a little help from this StackOverflow question and this MSDN sample … that is what I did. It seems to work nicely. Let me know if you have any problems with it.

Snoop(ing) Visual Studio 2010

Finally, ever since I’ve installed Visual Studio 2010, I’ve wanted to take a peek under the covers with Snoop (remember … Microsoft used WPF in this latest version of Visual Studio). I originally thought I couldn’t Snoop it … because it was running as a 64-bit application and I only had a 32-bit version of Snoop.

So, when I got the 64-bit version of Snoop going, I quickly tried Snooping Visual Studio 2010. No luck! Bringing up task manager, I quickly remembered that Visual Studio runs as a 32-bit application on 64-bit operating systems. See this post by Rico Mariani for more info.

As I have recently been invited into the WPF Disciples group, I posed the question there. Imagine my surprise to find out that devenv.exe was manually being filtered out (since Visual Studio 2008 would load WPF assemblies … but Snoop would fail since Visual Studio 2008 wasn’t built with WPF).

That gave me quite the chuckle. Or, more like, duh! So, promptly removed that and Snoop(ed) Visual Studio 2010 to my delight (check out the red Snoop adorner):


And, of course, the Snoop AppChooser:


And, finally, the main Snoop user interface:


I think that is so cool. Ok, I know … I need mental help. 😀

The Source Code

In the past, I have not released the source code since I have wanted to get Pete’s permission before I do so. I actually met him at PDC 2009 this year. I brought up the fact that I had modified Snoop to handle interop scenarios … but I forgot to ask him about the source code!

There are so many changes now … that I think it would be counter-productive to not release it … in case someone else wants to take Snoop even further than I (and Dan and Mark) have. If you do modify it … and take it further … please let me know! I would love the chance to determine whether to integrate the changes into this version.

So, here it is: the source code.

(The source code is now (see posts: 1, 2) up on CodePlex. Please go download it from there as that code will contain the latest and greatest bits.)


p.s. If you were one of the few who pulled down the binaries immediately after I posted it, then you may not have gotten the Snoop.exe.config file. Unfortunately, in this case, Snoop does not seem to close down all the way (i.e. I had to manually kill it through task manager). You’ll want to get the latest binaries that do include the Snoop.exe.config file … or manually rebuild them yourself with the source code.

An Update

See above (in the table of improvements), but I fixed the installers and integrated a nice idea by Anvaka. All the attached binaries (which should be installers now) and source code have been updated.

40 thoughts on “Snoop: Now with 64-bit Support and More”

  1. Hi Cory,

    Thanks for this – it’s very useful. In the version I’ve built, I don’t see the “(Default)” combobox in the Properties panel when it’s running. Is there a trick to seeing that?


  2. @John Schroedl

    Thanks John.

    No, there isn’t a trick to that at all. I’ve never had problems with it showing up.

    Were you trying to integrate my changes with other changes?

  3. Hi guys,

    This is huge! Thank you very much!

    A few comments from me.

    1. Remove the auto refresh checkbox. I never use auto refresh, and every time before I Snoop, I press the “Refresh” button … just to be sure I’m snooping the latest version.

    2. Before every WPF developer in the world downloads this version, would it be possible to change this long tip in the status bar (Hold down Ctrl-Shift blah-blah) to “Keyboard.FocusedElement=”. It’s a little known fact that the link next to this tip shows the keyboard focused element. And, if you have ever tried to debug focus issues in a WPF application, you may also want to have FocusManager.FocusScope() in the status bar too. Here is my tweaked version:

    3. The problem John faced … is due to the installer project and the GAC. Now it doesn’t deploy the Snoop assembly into the GAC, and John seems to be using an old version … since the Injector loads the Snoop assembly from the GAC. To fix that, one should uninstall previous version of Snoop, and drag and drop newly built version into %windir%\assembly.

  4. @Anvaka

    Hi Anvaka … thanks for commenting.

    As to #1, some some colleagues of mine actually like the auto-refresh behavior (I do not, myself) and so I am going to leave that in for now … especially since auto-refresh is now OFF by default.

    As to #2, this is a very good idea. I like it and will try and see if I can quickly integrate it into what I’m sharing here with the world.

    As to #3, thanks for helping @John Schroedl out. I admit I am not an expert in Deployment projects and disabled it in the build configuration when something went wrong there … when I integrated the last changes. Maybe I should revisit that, so that people have the option of installing it yet again. I’ll see what I can do.

  5. Thanks for sharing this with the community. It’s a great help. I do have one suggestion/request: Snoop uses the default TextBlock defined in the application being Snoop(ed). My application is dark with white text. Therefore I cannot read anything in Snoop without first changing the default TextBlock Foreground color. I’d be happy to do it myself. Just need to go back and install C++ (I think).

  6. @David Martin

    Very interesting problem David.

    I tried this myself by creating a default style for a TextBlock and sticking it in the Application resources (of the application that I was planning on Snoop(ing)). And, sure enough, the main Snoop UI had white text everywhere (making it hard to read).

    This is due to the fact that the main Snoop UI is being inserted into the process being Snoop(ed).

    I tried a few quick things … to see if I could fix it (e.g. creating another default TextBlock style with black as the foreground and sticking that style in the Snoop UI resources section) … but nothing worked.

    I will have to think about this … and play with this some more to see if I can fix it.

    However, did you say you had a fix already? If so, send it on, and I will take a look.

  7. @John Schroedl

    If anyone has run into John’s problem, I recommend uninstalling all versions of Snoop (and making sure that Snoop and the managed injector assembly are not installed in the GAC) … and then reinstalling the new version.

    And, it helps that now there are installers for both x86 and x64. 😀

  8. Why does nobody put all changes together as an open source project (of course with the copyright holders’ consent), and incorporate more changes?

  9. @Matthijs ter Woord

    Pete Blois just got back in touch with me and I am in the process of moving this source code to CodePlex. It might be a little bit, though, I am quite busy on the work front.

  10. Well done Cory.

    Great news about getting this on CodePlex … have been waiting for that for a while.

    I thought maybe Snoop was not working on .NET 4 but perhaps I was seeing this 64/32bit issue.


  11. Hi all,

    Nice job. I have a question. I have a complex interface, based on WPF. Is it possible to use Snoop programatically in a test automation manner?


  12. Rene: As far as I know, Snoop wasn’t really developed with this in mind … but maybe you can use WPF’s inherent UI Automation support to accomplish what you are trying to do.

    Let us all know … by commenting back here … if you dive in on this.

  13. Has this been moved to CodePlex yet? And if not, at a minimum what is the actual licensing of this tool? It doesn’t seem to be Open Source and the assembly info seems to insinuate it is owned by Microsoft. Great tool, but unusable in any corporate environment where licensing is strictly enforced!

  14. Great question about licensing, @pkordes! I just assumed Ms-PL, but I will email Pete Blois.

    I have been so busy on the work front … but I hope to get this project published very soon. I’ll let everyone know when I do.

  15. @pkordes, I just got word back from Pete Blois. Snoop will indeed be licensed as Ms-PL and I will shortly be updating the copyright information in the source code.

  16. Fantastic! I am going to start with using what you have so far then, but please reply to this thread once it is available on CodePlex. Thanks for understanding the necessary evil of licensing…

  17. Hi Cory,

    I was just wondering if there is any licensed version of Snoop to buy. If yes, kindly provide me the details ASAP.

  18. I wish that I could find a tutorial or something on using Snoop.

    I just downloaded it. I have a WPF 4.0 app running and would like to “Snoop” it. I click “Refresh” and expect that all the WPF applications would show up in the combo box but still nothing.

    How can I figure out how to get started with this cool tool? It sounds very useful and simple to use, but I am having no luck.

    Please help get me off the ground.


  19. Ok, I got the 32 bit version and I am finally able to find things running in Visual Studio. To be able to Snoop an app, must it be running in Visual Studio?

    Wow! Been messing around with it. This is looking good now. I held down Ctrl-Shft, moused around the app and things became alive. I can find things that my mama didn’t know about or where they are.

    Hey thanks Cory, it is late now but I can’t wait until tomorrow morning to get started at some depth. Please think about a quick start tutorial for dummies or something. Maybe with levels like 101, 201, 301, 401, graduate and post grad. This is really telling me a lot about WPF!

  20. @Les, currently there are 4 different versions of Snoop and you need to make sure you are using the correct one depending on your scenario.

    That is, if you want to Snoop a 32-bit application that has been built with WPF 3.5, you need that version. If you want to Snoop a 32-bit application that has been built with WPF 4.0, you need that version … and so on.

    I hope to fix this in the near future … as a fellow has already sent me changes to Snoop such that there is only one version and it figures out for itself how to handle the different situations. But as it stands, right now, you have to do that yourself.

    I bring this up … because you mentioned only seeing Visual Studio (with your application that you want to Snoop) in the application chooser’s combo box. This is because Visual Studio runs as a 32-bit application. I would speculate at this point, that the application you want to Snoop is a 64-bit application. Thus, if it is a WPF 4.0 application, you would need the WPF 4.0, 64-bit version of Snoop to do so.

    Again, I hope to fix this soon.

  21. @Les, as to your comments about a tutorial on how to use Snoop … this is high on my list of things to do.

    I hope to actually record some quick 5 minute screen casts, posting them to my blog and to the site.

    I also plan on building out the documentation section of the CodePlex site.

    However, for now, the best source of info on how to use it, would be at Pete Blois’ site. Just scroll down a little.

    Glad to hear that you’re loving Snoop. 😀 It is an extremely useful little utility for WPF (for learning, diagnosing, and more).

  22. Hi Cory,

    You are my best friend now. Careful, some people might not be happy if I told them that!

    But anyway, Snoop helped me find a binding error that has been messing with me for about 3 days. Driving me nuts! I haven’t found WPF to be too helpful at pointing out binding problems. It just quietly doesn’t work. No exception, no complaining, it just doesn’t work!

    This problem is why I was looking for a tool like Snoop last night. When I found Snoop, it looked like it might help me solve my problem. This morning, once I figured out what it could do and how to work it (still feebly I must admit), I quickly found the problem.

    I hope that you are having a great day … I am now.


  23. @Les, I’m happy to hear that Snoop helped you find your issue.

    I just thought I would point you to a cool feature in Snoop in regards to binding errors. There is an editable combo box above the visual tree that allows you to filter the visual tree. But, if you pull down the combo box, you can select an item in the combo box that states ‘Show only visuals with binding errors’. This item will filter the tree to only the items that have data binding issues. (To clear the filter, select the editable text in the combo box and just hit the delete key.)

    Just a tip for being so kind!

  24. Thanks Cory, that is a cool little tip! I wish that I had known that when I had the problem. I just fished around the areas where I thought that the problem was and found them that way. But it is also helpful now because it tells me that there are no more binding problems. Thanks again, keep up the good work and have a nice day……Les.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.