snoop show app, but can't snoop

Nov 30, 2010 at 12:58 PM

Hi,

 

I just downloaded latest snoop and tried to snoop a 64bit WPF app on Win7. Although the app appears in the combobox, pressing the snoop icon does nothing. However, as I tried to snoop VS2010 it works fine -> snoop window poped up.

 

Any idea?

 

Thanks in advance

Coordinator
Nov 30, 2010 at 4:09 PM

In a previous issue, I discovered that the MSVC++ redistributables need to be on the machine. For example, Snoop needs MSVCR100.dll to run ... in the case of Snooping a WPF 4.0 application. See if you can find this dll on your machine. If it isn't there, install the MSVC++ redistributables.

If that isn't the problem, you can download the source code yourself and try debugging to see what's wrong ... or ... if you have a simple test harness, you can send it to me at my first name followed by my last name at gmail.com. I'd be happy to take a quick look.

Nov 30, 2010 at 4:59 PM

Thanks for follow up.

 

I just checked: MSVCR100.dll is on my machine -> should not be the problem.

 

I also just tried to create a small sample app, but this worked as expected.

 

I'll get back to you as I have more time to debug snoop.

 

Thanks.

Dec 8, 2010 at 11:33 PM

I've noticed the same thing that DierkDroth reports. I'm running on a 64-bit Win7 machine and my app is WPF 4.0. I can snoop VisualStudio, but when I click to snoop my app I get a brief spinner but nothing happens.

Clicking on magnify does work, though. I just can't snoop.

Dec 9, 2010 at 12:44 AM

I downloaded the source to see if I could find out what was going on. For me, it was crashing with a null reference exception in SnoopUI's ctor, on PresentationTraceSources.Refresh() (the exception was thrown deep down in System.Diagnostics.FilterElement.RefreshRuntimeObject).

Not knowing what this call is supposed to accomplish in your app, in typical software developer fashion I skipped over the call and now everything seems to work. So I made myself my own version of your tool that catches this exception and warns the user but keeps running.

Does your app rely on the output from the trace listeners, or is this a "valid" fix?

Dec 9, 2010 at 1:44 AM

Interesting - sometimes I get the following error while running the debug build of snoop then trying to load my application:

Error reading user filters from settings. Using defaults.

The property 'PropertyFilterSets' could not be created from it's default value because the default value is of a different type.

I haven't gotten the error yet when launching snoop from within visual studio, so I'm not sure what's causing this error or whether it's related.

Coordinator
Dec 9, 2010 at 2:59 PM
bsegraves wrote:

I downloaded the source to see if I could find out what was going on. For me, it was crashing with a null reference exception in SnoopUI's ctor, on PresentationTraceSources.Refresh() (the exception was thrown deep down in System.Diagnostics.FilterElement.RefreshRuntimeObject).

Not knowing what this call is supposed to accomplish in your app, in typical software developer fashion I skipped over the call and now everything seems to work. So I made myself my own version of your tool that catches this exception and warns the user but keeps running.

Does your app rely on the output from the trace listeners, or is this a "valid" fix?

Thanks for posting, bsgreaves, ... I will look into this.

Dec 9, 2010 at 4:48 PM
Edited Dec 9, 2010 at 5:29 PM

So I tried calling PresentationTraceSources.Refresh() from within my own app and wouldn't you know it - I get the same NullReferenceException. I was able to find the offending line in my app.config and comment it out, however attempting to create a test app with just that config option failed to produce the error in the test app. We have a pretty big WPF app, so there's something else going on.

For what it's worth, our app.config had the following section:

	<system.diagnostics>
<sources>
<source propagateActivity="true" name="System.ServiceModel" switchValue="Information, ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type=""/>
</add>
<add initializeData="c:\app.svclog" type="System.Diagnostics.XmlWriterTraceListener" name="traceListener" traceOutputOptions="Timestamp">
<filter type=""/>
</add>
</listeners>
</source>
</sources>
</system.diagnostics>

If I commented out the empty filter types, my app no longer crashed when I called PresentationTraceSources.Refresh(). Also, my app now loads with Snoop 2.6.0 - I no longer need to use my homebrew version.

Hope this helps.
Mar 17, 2011 at 3:40 PM

We were also getting this issue (SnoopUI not showing up after injection); and I came to the same NullReferenceException when trying to debug it.

Commenting out/removing empty <filter/> Elements does indeed fix this problem, but this really sounds like an issue that should be on Connect.

Coordinator
Apr 8, 2011 at 3:09 PM

Just going through my inbox and cleaning up some stuff ... this is very interesting ... and I just wanted to thank you guys (bsegraves and BhaaL) for posting your experiences.

I will definitely point others to this discussion as something to try out/look into ... when they can see their app in the app chooser but are unable to Snoop it due to a NullReferenceException.

May 10, 2011 at 6:04 PM

Has anything been done on this? I have been using Snoop on an app in development for some time, and just today it's won't let me. Like others have described, the app shows up in the drop-down, but clicking the "Snoop" button doesn't do anything. I can magnify without problem.

Coordinator
May 10, 2011 at 7:00 PM

Have you tried the suggestion that @bsgreaves gives? Have you tried debugging it yourself (after dowloading and compiling the source code)?

Note that the issue, that the workaround @bsgreaves helps with, has nothing to do with Snoop. Admittedly, it would be nice to have some sort of message when Snoop(ing) fails ... that hopefully also has a clue of why it failed ... but I haven't gotten to that yet.

Post back here, especially if it is a different issue ... or simply create another discussion item.

Good luck! Let me know how it goes ... or what you find out.

May 11, 2011 at 2:09 PM

Hello,

Thanks for the reply. I couldn't try that suggestion, because I couldn't build the solution. When I loaded it up, I got multiple errors of the form "...\Snoop\ManagedInjector\ManagedInjector32-3.5vcxproj cannot be opened because its project type (.vcxproj) is not supported by this version of the application." There are four projects with similar names that are unavailable, as is the SnoopInstaller project.

I haven't a clue what this means! I'm using VS 2010 professional if that helps.

What I don't understand is that Snoop has been working fine since I downloaded it (some time ago), and only stopped working yesterday. I don't know of any changes to my machine.

Thanks for any help you can give. All I want is my Snoop back!

Coordinator
May 11, 2011 at 3:10 PM

.vcxproj is the file extension for C++ projects. Did you not install C++ support when installing Visual Studio?

Try doing that and rebuilding ... and then debugging, obviously.

May 11, 2011 at 5:18 PM

Duh! No, I never use C++, so didn't bother installing it when I installing VS. Ho hum, looks like I'm going to have to do that.

Thanks, I'll try it and see how I get on.

May 15, 2011 at 12:18 PM

OK, installed C++ now, but got the error "blah\SnoopInstaller\SnoopInstaller.wixproj cannot be opened because its project type (.wixproj) is not supported by this version of the application." From what I can see, this is to do with Windows Installer. Don't know if I need this just to run the solution.

Anyway, when I tried running it, it failed to build. I got four errors, which were actually the following two twice each...

The referenced assembly "C:\...\Build\Debug\ManagedInjector32-3.5.dll" was not found. If this assembly is produced by another one of your projects, please make sure to build that project before building this one.    ManagedInjectorLauncher32-3.5

error MSB8009: .NET Framework 2.0/3.0/3.5 target the v90 platform toolset. Please make sure that Visual Studio 2008 is installed on the machine.    C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets    292    6    ManagedInjector64-3.5

The first error was in the ManagedInjectorLauncher32-3.5 project (no file, line or column), and the second was in the ManagedInjector32-3.5 project, file Microsoft.CppBuild.targets, line 292 column 6.

Actually, just noticed that the duplicated errors were actually different, in that one was in the ManagedInjectorLauncher32-3.5 project, and the other was in the ManagedInjectorLauncher64-3.5 project. Similarly for the second error.

Anyway, I looked in the SnoopUI ctor as suggested, and it had this code...

      try {
        PresentationTraceSources.Refresh();
      }
      catch (Exception ex) {
        MessageBox.Show("Exception: " + ex.Message);
      }

...so if the problem is the same one as suggested before, I would have expected a message box to pop up. That assumes that the installed version of Snoop I have is the same one as in this source code, but as I have (I think) the latest release (2.6.1), it should be.

Did I miss something else when I updated VS? Any other suggestions? Thanks for any help. I really would like to get Snoop working again.

Thanks

Coordinator
May 16, 2011 at 6:34 PM

MrYossu,

Yes, unless you have WiX installed ... the installer project will not load. That shouldn't stop you from building things (in Debug at least ... the Release configuration does try to build the installer).

Snoop is an application that targets .NET 3.5 ... so that it can Snoop both 3.5 and 4.0 applications. So, in order to build Snoop you will also need to install .NET Framework v3.5 SP1. I do not think you need to install Visual Studio 2008, but I am not 100% positive. I would first install .NET Framework 3.5 SP1 and see if that resolves your not being able to build Snoop. If it doesn't, please post back here ... I would want to know that.

Both those errors you mention above ... are the result of not having .NET Framework 3.5 SP1 installed.

I am confused by the try/catch block you have in your reply ... in the current code, that isn't in place ... in fact, I don't know if it has EVER been in place. I actually do want to put some try/catch blocks (like that) in ... and also some unhandled exception handlers ... in conjunction with log4net ... so that I can more easily help people (like yourself) who have issues with Snoop(ing) something.

So ... you likely put that try/catch in yourself. One thing to know ... is that there are two main pieces to Snoop: the piece that lives in its own process (the app chooser) ... and the piece that gets injected into the Snoop process. So, if the issue is happening on the app chooser side, the try/catch block you put in ... won't catch the exception.

Besides those two main pieces, there is also the injector assemblies and executables. It is possible, that the problem is occurring in one of them too.

One last thing. Apparently, Snoop doesn't handle Snoop(ing) on a different thread. I haven't verified this myself ... but another fellow has looked into it ... and has even provided a potential solution (patch) for it. See http://snoopwpf.codeplex.com/discussions/252086 for more info.

Good luck and keep me posted!

Cory

May 16, 2011 at 9:04 PM
Hi Cory, Thanks for the reply. Here are some answers...
Snoop is an application that targets .NET 3.5 ... so that it can Snoop both 3.5 and 4.0 applications. So, in order to build Snoop you will also need to install .NET Framework v3.5 SP1. I do not think you need to install Visual Studio 2008, but I am not 100% positive. I would first install .NET Framework 3.5 SP1 and see if that resolves your not being able to build Snoop. If it doesn't, please post back here ... I would want to know that.

Both those errors you mention above ... are the result of not having .NET Framework 3.5 SP1 installed.


OK, well I just checked, and I have loads of versions of .NET, including 3.5. I'm not sure if I have 3.5 SP1 or not though. I just downloaded the installer for that, but it doesn't do anything when I try to run it, so it might just have detected that I already have it installed.

I am confused by the try/catch block you have in your reply ... in the current code, that isn't in place ... in fact, I don't know if it has EVER been in place. I actually do want to put some try/catch blocks (like that) in ... and also some unhandled exception handlers ... in conjunction with log4net ... so that I can more easily help people (like yourself) who have issues with Snoop(ing) something.

So ... you likely put that try/catch in yourself.

I did touch the source code. I grabbed the latest version from codeplex and opened it up. That try/catch block was already in there. I looked for the ctor in SnoopUI as mentioned by bsgreaves. and there it was.

One thing to know ... is that there are two main pieces to Snoop: the piece that lives in its own process (the app chooser) ... and the piece that gets injected into the Snoop process. So, if the issue is happening on the app chooser side, the try/catch block you put in ... won't catch the exception.

I was working on the comments from bsgreaves above, and searched the entire solution for "PresentationTraceSources.Refresh"

I only found one of these, so assumed that was the one he meant.

OK, at this point I'm lost. I haven't had time to look through the Snoop source much (not that I would understand it, C++ isn't my strong point). I just want to have Snoop working again.

Any ideas what I can do? It used to work, but now doesn't. I have no idea why as the solution hasn't changed that much.

Thanks for any help.

Coordinator
May 16, 2011 at 10:28 PM

MrYossu,

Well, maybe you do need to install Visual Studio 2008. If you still can't build Snoop, and you have .NET 3.5 SP1 installed ... the next thing to do is install Visual Studio 2008.

Are you sure that you are looking at the current code (from the 2.6 branch) for Snoop? That try/catch is not around the PresentationTraceSources.Refresh call. If your code has it ... then I am not sure what code you have at all.

Regardless, if you aren't getting a NullReferenceException from the PresentationTraceSources.Refresh call ... then your issue is likely not bsgreaves.

The only thing I can tell you to do is to get to a point where you can compile and debug Snoop ... and see what you can find. So, install Visual Studio 2008 and see if that helps you compile Snoop.

Cory

p.s.

The released bits of Snoop (v2.6.1) are significantly out of date with the latest bits available at http://snoopwpf.codeplex.com/SourceControl/list/changesets. However, that try/catch is not in any version of code ... as I have already mentioned.

p.s.s.

I'm sorry Snoop isn't working for you. I know it is painful to not have it working ... that is how I got into maintaining Snoop, actually. That is, Snoop wasn't working for our interop scenario and I worked to figure out why and fixed it. I made those changes available ... and the rest is history.

May 17, 2011 at 10:39 AM

Hi again Cory,

I just downloaded the source code again, and it doesn't ahve the try/catch in it. I'm confused now, I'm sure I didn't add it yet! Must have been a senior moment!

Anyway, I installed VC++ 2008 Express, and that allows me to build all but the ManagedInjector64-3.5.dll project, which gives the error...

"error MSB8014: Execution path (C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\x86_amd64) could not be found."

If I look in the VC++ install directory, it isn't there. If I run Snoop, it asks me if I want to build this project as it's out of date. If I say no, it still runs, and seems to work. With a try/catch around the call mentioned before, it gives a message box about a null reference, but does seem to work.

So, it looks like I might be back in business. Can I just copy the Snoop.exe file into my current install directory, or do I have to uninstall my current version and install this one properly? If so, what do I need to do to install it?

Thanks again for all your help. I'll be so relieved when Snoop is working again! I really don't know why this functionality isn't built in to VS already. I can't imagine writing WPF applications without Snoop.

Coordinator
May 17, 2011 at 2:49 PM

I didn't know this till now (I've never used the Express version of Visual Studio 2008) ... but that version doesn't support 64-bit, C++ projects ... see http://en.wikipedia.org/wiki/Microsoft_Visual_Studio_Express for more info. So, that is why that one project isn't compiling.

However, if you aren't on a 64-bit operating system, then it shouldn't be a problem. (If you don't want the error when compiling in the future, simply unload that project from the solution.)

If it was me, I would uninstall the old version that you have (so there is no possibility you are running something that doesn't work for you), and simply run Snoop from where you compiled it (create a shortcut to it).

Hmm. So ... we finally get to the issue. Do I understand that you are indeed getting a null reference exception from PresentationTraceSources.Refresh? If so, then maybe your issue is the same as bsgreaves' issue. If that is the case, I would definitely try the workarounds that he has posted earlier in the thread (i.e. modifying the app.config ... or simply commenting out the PresentationTraceSources.Refresh call).

It sounds like you are back in business!

p.s.

The PresentationTraceSources.Refresh call has to do with showing data binding errors when they occur. I have not played with commenting it out ... to see if it has any ill effect ... but if it has any, it would be with showing data binding errors in the property grid.

May 17, 2011 at 3:59 PM

Do you know, if I ever learn to read, it might be quite useful! I was so busy trying to work out what was going on, that I didn't read bsgreaves' post properly. A brief look told me that it wasn't my problem as I wasn't doing anything so clever as using listeners.

I just looked at the app.config, and found empty filters in the listeners section! I commented these out, and Snoop works! Hurray, I've got my Snoop back!

Thanks very much for all your help. It might be worth doing something with that call in the release version, to avoid this problem for others.

Coordinator
May 17, 2011 at 7:46 PM

Glad to hear that you're finally Snoop(ing) again.

I think that I will definitely do something about this issue ... so that this problem doesn't plague others. At the very least, I can put a try/catch block around that call ...

Coordinator
May 17, 2011 at 7:56 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
May 18, 2011 at 10:07 AM

Thanks Cory. I added a comment there in case anyone doesn't read this thread.