Snoop Tips & Tricks #3: The Crosshairs

Ok, I know it has been forever since the last Snoop trick! My apologies! I have a whole list of things that I want to show off … but, man, where do people find the time to do these types of things?! Thinking smile

Often, I have had to choose between working on Snoop … versus documenting what it can do. I have often chosen the former because I think that Snoop is fairly obvious to use … but then I am reminded that I am an expert user of it and that many of its features are really quite hidden. For example, how can you easily select the visuals you want to Snoop on? Why, with the Ctrl-Shift Mouse Over trick, of course. Our first two tricks (Trick 1, Trick 2) covered that particular piece of hidden functionality.

Since those tricks, we have had a couple releases of Snoop (2.7.0 and 2.7.1). We have even converted the CodePlex Snoop repository to Git and also have a sibling repository at GitHub.

So, in this trick, I want to show off a new piece of functionality that we introduced in version 2.7.0 … what I like to call the crosshairs functionality.

This functionality is all about avoiding the combo box of Snoopable applications. It took forever to iterate over all the applications on the system … seeing if each one was a WPF app or not … and filling up the combo box as we go. Why couldn’t we just select that app that we want to Snoop with the cursor? And that is exactly what we did.

Snoop Tips & Tricks #3: The Crosshairs


Now, it is super fast to Snoop an app! You simply launch the Snoop app chooser, drag the crosshairs on top of the app you want to Snoop … and wham bam … you are Snooping.

Thank you Anvaka for implementing this feature!

Happy Snooping!

Snoop Tips & Tricks #2: Snooping Transient Visuals

In this trick, I show you how useful the prior one can really be.

That is, it can be used to Snoop transient visuals … or visuals that aren’t currently in the visual tree. A perfect example of this type of visual … are combo box items.

Snoop Tips & Tricks #2: Snooping Transient Visuals

One thing I forgot to mention in the video … check out the root of the visual tree after I have used the Ctrl-Shift Mouse Over trick on the combo box item … it is not an App object … but a PopupRoot object. This is further indication that Snoop has refreshed the visual tree and placed the transient visual there in place of the normal App object.

Happy Snooping!

Snoop Tips & Tricks #1: Ctrl-Shift Mouse Over

I am always surprised how many people don’t know about this trick … but I guess it isn’t really obvious since I removed the tip from the status bar … in favor of some keyboard functionality.

I thought the best way to show this trick off … is with a screencast. Enjoy!

Snoop Tips & Tricks #1: Ctrl-Shift Mouse Over

Snoop: Now Supports WPF 4.0 Even Better in Snoop v2.6.1

Problems, Problems

The above blog post title is supposed to be kind of a joke. I keep telling people I’m funny. Snoop supposedly has been supporting WPF 4.0 for some time now. Unfortunately, however, there were times where (1, 2) WPF 4.0 applications weren’t showing up in the App Chooser.

In one situation, PresentationFramework.dll wasn’t showing up in the list of loaded modules for the application being Snooped. So, I simply started searching for any of the following assemblies: PresentationFramework.dll, PresentationCore.dll, or wpfgfx_v0400.dll.

But, that didn’t work in all situations.

For sometimes, PresentationFramework.dll shows up as which I believe is the Ngen(ed) version of the assembly. At other times, it isn’t wpfgfx_v0400.dll that shows up in the list of modules, but wpfgfx_v0300.dll. The former is the milcore for WPF 4.0 and the latter is the milcore for WPF 3.5.

At this point, I just searched for the roots of all these names, i.e. PresentationFramework, PresentationCore, and wpfgfx.

But, again … that didn’t work in all situations. Humility, is a virtue … humility is a virtue. Annoyed

For some reason, at times, these modules show up in lower case. Don’t ask me why. If someone can shed light on this, please do. So, I’m now searching for the roots of these assemblies in a case-insensitive way. Granted, I probably should have seen that one coming.

Snoop v2.6.1

Now announcing Snoop v2.6.1!

Snoop v2.6.1 fixes these issues and others. After yet another fellow experienced this problem and since more people are going WPF 4.0 all the time … I figured it was time for a release.

This release also contains some usability improvements from fellow Snoop aficionado, Dan Hanan. In particular:

  1. You can now delve properties by double clicking on the name.
  2. You can now modify the filter sets to contain what you wish to be filtered.
  3. You can now use the mouse wheel to modify property values.
    I also want to say that I have a whole bunch of things lined up for integration into Snoop, but have been struggling to find time. For example, another fellow added the ability to capture some hi-res screen shots from Snoop. So, there is definitely going to be a vNext for Snoop … and hopefully soon.

Snoop Tips & Tricks

For a while now, I’ve been contemplating a blog series on Snoop where I highlight different tips and tricks, and in general, how to use Snoop. And with this release, I’m going to kick it off with the most important one of them all: the Ctrl-Shift Mouse Over trick.

Snoop: Yes, You Can Snoop XBAPs

Today I got a question about whether Snoop supports XBAPs. Actually, this is something I’ve been meaning to look into for a while.

So, I took the two necessary seconds to create a test XBAP project and tried Snooping. It didn’t work. When launching Snoop after running the XBAP, you see PresentationHost.exe in the App Chooser (PresentationHost.exe is the process that the browser launches in the case of an XBAP).


However, trying to Snoop it (clicking the binoculars) … results in … nothing, not even an error.

Now, the person asking … pointed out a Josh Smith’s blog post on the matter … where he discusses three tips for working with XBAPs … one of which is that Snoop doesn’t work, but that Mole does. In order to get Mole to work, however, you must (at least temporarily) make your XBAP a full trust application.

Hmm. That got me thinking. Yes, I know that is dangerous.

A lot of my efforts with Snoop to date … have revolved around getting edge case scenarios to work … and I have modified the start up process significantly. So, I thought, I should quickly check to see if Snoop now works … as long as I change the XBAP to a full trust application.

And … woohoo … it works! Thumbs up

So, all you need to do is go to the Project Properties window, navigate to the Security tab, and check ‘This is a full trust application’.


Hope that helps, and yeah, Snoop rules!


I did also verify (while writing up this post) that neither Snoop 1.0 (Pete Blois’ original version) nor Snoop 2.0 (Pete Blois’ newer stylized version) worked with XBAPs.

.NET Reflector Pro: Debugging the .NET Framework Source Code

The other day, I ran into a situation (see the attached project and here for more info) where I wanted to debug the .NET Framework in order to see how something was working.

Unfortunately, Visual Studio’s native support (see Scott Guthrie’s blog post or Shawn Burke’s blog post) for doing so was failing me. I was eventually able to get that working for .NET 4.0 but not .NET 3.5 SP1 (see this forum thread), but in the meantime … I had to turn to other methods.

So, what is one to do when this happens? Is all lost? Not at all, for you can use .NET Reflector Pro to do the same thing.

.NET Reflector is a very popular .NET utility created by a Microsoft employee, Lutz Roeder. It allows you to explore and analyze .NET managed assemblies. This utility can also be extended by way of add-ins and there is a whole bunch of them out there.

A while ago, Lutz Roeder, decided to let Red Gate take the reins, and they then went ahead and added the ability to allow a user to debug into third-party code and assemblies by way of a Visual Studio add-in.

And that is what I’m going to show you how to do, step-by-step.

Install .NET Reflector Pro

The first thing that you need to do, obviously, is to download and install .NET Reflector, if you haven’t already. There is a download link here.

It comes down as a zip file, so simply extract the contents to a convenient location. Launch it and then select Tools->Integration Options. Here is the dialog that comes up.


This dialog allows you to easily install the .NET Reflector add-in … into Visual Studio. Choose the versions that you want and click OK.


Tell Visual Studio to Disable Optimizations

The next step is very important. If you forget it, you will be frustrated once you get to actually debugging the source code … because all the variables will be optimized away and Visual Studio will also step through the code in odd ways.

So, go to my earlier blog post and follow its instructions. (Also, don’t forget, if you are debugging a Visual Studio 2010 application, to make sure you update the path to devenv.exe … in the .cmd file you create in this step.)

Choose the Assemblies to Debug

Next, launch Visual Studio with the .cmd file from the previous step and load up the project that you want to debug. Go to the .NET Reflector menu and select ‘Choose Assemblies to Debug…’


If you don’t have your options set correctly, the following dialog will come up. Click ‘Turn off “Enable Just My Code”’ to continue.


Now, choose which assemblies that you wish to debug into … via the following dialog.


In my case, I want to debug the ContentPresenter.EnsureTemplate method and the ContentPresenter class lives in PresentationFramework.dll. How do I know this? Well, through .NET Reflector, of course.

Activate .NET Reflector Pro

Once you click OK to the above dialog, you may get prompted with the following dialog.


This, unfortunately, brings up an annoying issue. Even though Red Gate has kindly provided a 14-day trial to use the Pro features of the tool … your trial starts when you install the software and not when try to use the debugging feature for first time.

That is, for me, I was never able to take advantage of the trial period as I had long had the software installed (it is always one of the first pieces of software I put on a newly paved development machine).

So, if you are in this situation, go buy a license and then Activate it here.



Let .NET Reflector Decompile the Assemblies

5. At this point, .NET Reflector Pro is disassembling the assemblies that you have chosen and also reassembling them so that they can generate .pdb files. This process takes quite a bit of time and so they also stuff the output into the ‘Debug Store’ so that you don’t have to do this every time.


If you’ve been around the .NET world for a bit, you’ll notice the similarities in the above step to what you had to do manually in this CodeProject article. And, if you recall, what you ended up debugging … was IL, not C# or VB.

Eventually, everything will succeed.


Verify Your Tools->Options Debugging Settings

At this point, bring up the Tools->Options dialog and go to the Debugging/General tab. Everything should be fine, but as a point of education … and to verify that everything is okay … make sure that all settings pointed to by the red arrows are set as shown.


.NET Reflector cleared the first one (‘Enable Just My Code’) for you … but make sure it is unchecked.

Also, make sure that ‘Enable .NET Framework source stepping’ and ‘Enable source server support’ are unchecked. These options are checked when you are using Visual Studio’s native support to debug into the .NET Framework (mentioned above) … but we don’t want them checked now … so that there is no cause for confusion.

Finally, the ‘Require source files to exactly match the original version’ is not strictly necessary. However, I believe I have had issues in the past if this was checked. If you leave it checked, just keep it in mind, so if things aren’t working you can then try unchecking it.

Next, check out the Debugging/Symbols tab. Below, you can see where .NET Reflector has installed the .pdb files. Make sure those locations are checked … and make sure that everything else in that list is unchecked … especially ‘Microsoft Symbol Servers’

And, very importantly, make sure you have a clean symbol cache … by clicking the ‘Empty Symbol Cache’ button. Why is this important? Well, it ensures that all the .pdb files will be coming fresh from Reflector … and won’t be a stale .pdb from a previous effort at trying to use the native Visual Studio support.

What is the Symbol Cache? Well, the Symbol Cache is where the .pdbs are copied to … so that you don’t have to keep downloading them from the Microsoft Symbol Servers … obviously an important option when using the native Visual Studio support … but not super important when dealing with .NET Reflector. However, I believe Reflector’s .pdb files still get copied to the Symbol Cache.


Debug the .NET Framework (Call Stack Approach)

Now, you need to figure out how to set a breakpoint so that you can break into the application and debug the .NET Framework. The first mechanism is just to set a breakpoint on a local (non-framework) method that you know will cause the class of interest to be on the stack. Then you can double click the stack frame and set another breakpoint as necessary.

For example, let us say that I want to debug System.Windows.Application.DoStartup. I know that the Application class will probably be on the stack if I put a breakpoint in the InitializeComponent method of my MainWindow. So, that’s exactly where I put it.


Now, I click Debug->Start Debugging (F5) and hopefully I will hit my breakpoint. Sure enough:


One thing to note here is that gray text indicates that a .pdb has not been loaded for that assembly while black text indicates that a .pdb has been loaded. That is, in the above example, only PresentationFramework has an loaded .pdb.

And, look! Application.DoStartup is on the stack. Double click that stack frame to bring you to the code.


At this point, you can debug as normal. You can step, watch variables, and more. In the above screen shot, you can see that I set a new breakpoint at the start of the method to be hit when I restart the debugging session. Restarting the application, shows that I can verify that MainWindow.xaml is my StartupUri.


Debug the .NET Framework (Method Breakpoint Approach)

Unfortunately, the above call stack approach to debugging the .NET Framework will only get you so far. Another method I have used in the past is to simply set a breakpoint on a method name. How to do this is not very obvious, though.

The trick is to set a breakpoint via the New->Break at Function menu item in the Breakpoints debugging window.


The New Breakpoint dialog comes up. Simply, and carefully, type the name of the method, prefixed by its Class name, like so:


It will complain, but just click OK.


At this point, just hit F5 (Debugging->Start Debugging) and do what you need to do to hit the breakpoint. And, wa la, here I’ve hit my breakpoint:


The real question that prompted all of this desire to debug the .NET Framework was to see whether the DataContext was getting set or cleared inside of ContentPresenter. And so, I set the following breakpoints and step to my hearts content.



Sometimes, you are up against the wall. You are trying to determine if the .NET Framework has a bug in it … or you’re just trying to get a better grasp about what is really going on in that big black box.

And, while debugging the .NET Framework is best done natively inside of Visual Studio (it’s easier and you can see comments in the source code), it doesn’t always seem to work. Sometimes the assembly you are trying to debug is not supported and at other times the symbol servers don’t seem to be up to date with the released bits.

However, .NET Reflector Pro can come to your rescue in these situations. It can also debug any third-party assembly, regardless of whether it’s Microsoft’s or not.

Good hunting … I hope this helps someone out! Leave a comment if it does!

Snoop: There can be only one!

Haven’t I already said that the community has just been awesome in regards to Snoop?

Well, here is another piece of evidence!

The other day, a developer, Bruno Martinez, from Uruguay contacted me and wanted to contribute to Snoop by making it so that there was only 1 version, instead of the 4 currently required at that point.

If you recall …

  1. You needed a version for WPF 3.5 and 32-bit.
  2. You needed a version for WPF 3.5 and 64-bit.
  3. You needed a version for WPF 4.0 and 32-bit.
  4. You needed a version for WPF 4.0 and 64-bit.

Yuck! Of course, it was better than not being able to Snoop in those situations. 🙂

Well, after integrating Bruno’s changes … you just need:

  1. Snoop


Yeah, that’s right. There are no labels! Thank you, Bruno!

I’m obviously tickled by this … since it was a usability nightmare trying to figure out what version you needed to run … but there are host of other fixes/improvements as well. In particular, the Snoop start-up process is much more robust than it used to be and it can handle some fringe cases that it wasn’t able to before.

Please go to for more info, and of course, the download/release area for version 2.6.0.

Happy Snooping!

Snoop: Now Supports WPF 4.0

This is just a quick post to point people to the fact that I have updated Snoop on CodePlex ( such that it now supports WPF 4.0.

If you try to Snoop a WPF 4.0 application with the WPF 3.5 version, you will get the following error message:


I speculate that this is because there is a brand new CLR with .NET 4.0 (WPF 4.0) applications. Yes, that’s right, a brand new CLR. We haven’t had one of those for a while.

If someone can confirm this or provide a better understanding of why I can’t Snoop WPF 4.0 applications without retargeting Snoop to .NET 4.0 … please shed some light for me.

So, there are now 4, count them, 4 versions of Snoop:

  1. Snoop 32-bit for WPF 3.5
  2. Snoop 64-bit for WPF 3.5
  3. Snoop 32-bit for WPF 4.0
  4. Snoop 64-bit for WPF 4.0
    You need to use the right version of Snoop in each particular situation … otherwise … thar will be problems, matey!

I have also added another label to the app chooser so that you know which version you currently have up. Take a look … this is what it looks like for the 64-bit/WPF 4.0 version:


Let me know if you have any problems by creating a discussion (or participating in a current one) on the site.

Enjoy and happy Snooping! 🙂

Snoop: Now on CodePlex


Snoop is now on CodePlex at

The community reception to my efforts (blog posts: 1, 2, 3) on Snoop have been wonderful. Some like Anvaka have offered additional feature suggestions; others have just encouraged me.

In my last post, a fellow commented asking why it wasn’t up on CodePlex. Well, this was a great suggestion and one that I had actually already considered. That prompted me to email Pete Blois (the original author) for his permission. He graciously gave it and so I then proceeded to put it up there.

It took me a little while, but I now have the initial bits uploaded … that is, the same stuff that is available here at my blog.

Now, there are a bunch of things on the todo list. Most notably, I’ve already modified Snoop so that it works for WPF 4.0 … and definitely want to share that with the world.

So, please be patient, I’ll get to it. Those silly day jobs! 😀

Some Info

If you are going to download the source code and build it, some comments are in order (I’ll put this out at the CodePlex site too).

There are (go to Build->Configuration Manager) 3 solution platforms (x86, x64, Any CPU) and 2 solution configurations (Debug, Release). The x86 platform is for 32-bit, the x64 platform is obviously for 64-bit, but … what is Any CPU?

Well, Any CPU is only around for Blendability. That is, for some odd reason, I couldn’t bring up the Blend designer Snoop’s window unless it was in this configuration. I have intentionally marked the ManagedInjector project to not be built under the Any CPU configuration. Since Any CPU will run as 32-bit on 32-bit operating systems and as 64-bit on 64-bit operating systems, using Any CPU will likely cause a mismatch (and a headache :)) with the ManagedInjector dll.  The project which builds the ManagedInjector.dll is a C++ project and there isn’t an Any CPU setting for those (they can only be specifically built to Win32 or x64).

Or, in other words, make sure you switch into another platform, before you build or the build will fail.

Here’s a chart for quick reference:

Platform Configuration Notes
x86 Debug For 32-bit.
x86 Release For 32-bit, builds the installer.
x64 Debug For 64-bit.
x64 Release For 64-bit, builds the installer.
Any CPU Debug, Release Only for Blendability. Do not use.


Call to Action

If you have a feature request or want to be involved somehow (maybe as a contributor), please don’t hesitate to contact me.

For near future though, I’m going to keep the project closed until I can change the copyright info to Ms-PL and clean up the code a bit.


Finally, I want to publicly thank Pete Blois for first creating this awesome tool and for giving us the permission to get it going on CodePlex. A big thanks Pete!

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.