Using Snoop to take a look at VS2010 !

Update 18th january 2011: as Cory pointed out, the latest version of Snoop is now available on CodePlex.

If like me you’re curious about how big WPF applications are made, you probably tried to use Snoop to inspect the visual tree of Visual Studio 2010 Beta2. And you probably had a problem because Snoop wasn’t able to detect the devenv process of VS2010:

I wasn’t sure about the cause of this problem, but I grab the source of Snoop and took a look at the code that list the available window:

public void Refresh() {
	this.windows.Clear();

	foreach (IntPtr windowHandle in NativeMethods.ToplevelWindows) {
		WindowInfo window = new WindowInfo(windowHandle, this);
		if (window.IsValidProcess && !this.HasProcess(window.OwningProcess))
			this.windows.Add(window);
	}

	if (this.windows.Count > 0)
		this.windowsView.MoveCurrentTo(this.windows[0]);
}

I setup a breakpoint to find out what was wrong and discover that the window.IsValidProcess failed with the VS2010 process. Because I just wanted to check if it was the only reason why Snoop wasn’t able to inspect it, I hack the code to remove this test:

public void Refresh() {
	this.windows.Clear();

	foreach (IntPtr windowHandle in NativeMethods.ToplevelWindows) {
		WindowInfo window = new WindowInfo(windowHandle, this);
		if (/*window.IsValidProcess &&*/ !this.HasProcess(window.OwningProcess))
			this.windows.Add(window);
	}

	if (this.windows.Count > 0)
		this.windowsView.MoveCurrentTo(this.windows[0]);
}

And it’s working:

vs2010-snoop

Happy exploration with Snoop 🙂

7 thoughts on “Using Snoop to take a look at VS2010 !

  1. If you go one level deeper, you’ll see that IsValidProcess explicitly returns false for devenv, with a comment of “Remove VS, since it loads the WPF assemblies but we know that it doesn’t work”. Presumably this is referring to VS2008. So you should be able to just remove that condition and still filter out stuff that won’t work.

Leave a Reply

Your email address will not be published.