Introducing Customer Debug Probes and CLR SPY


Version 1.1 of the .NET Framework introduces a handy feature called Customer Debug Probes (CDP).  These probes enable you to find and diagnose difficult bugs lurking in managed code, even in a production environment.


I’ll share the details of each probe in future blog entries, so stay tuned.  In the meantime, I’ve uploaded a tool (with source code) to gotdotnet.com called CLR SPY that makes it easy to use the probes.  Here’s a screenshot:



CLR SPY runs in the taskbar notification area.  It can display balloon tooltips and/or log messages to a file.  Here’s an example of it in action:



To get a feel for the tool, add any managed application to the “Monitored Applications” list and run it with the Marshaling probe enabled.  You should see a flurry of messages appear as parameters get marshaled to unmanaged code.


This dynamic analysis tool is a great complement to FxCop‘s static analysis for writing high-quality managed code.  Use it to find your bugs before your customers do!  Let me know what you think of the tool!


Note: When using debug probes, you could run into bugs (or unwanted noise) in components you depend on – even in the .NET Framework!  For example:



  • Windows Forms applications that take advantage of the new v1.1 Application.EnableVisualStyles feature (which gives you Windows XP themes without the use of a manifest) trigger the PInvoke Calling Convention Mismatch probe when shutting down (or potentially other times, like if the application calls Application.DoEvents).  That’s due to a bug in a PInvoke signature inside System.Windows.Forms for the Win32 DeactivateActCtx API.
  • Unmanaged applications that load the CLR by cocreating a managed object on an STA thread provoke the Thread Changing Apartment State probe.  That’s because when the CLR is loaded, it tries to initialize the thread’s apartment state to MTA even though it has already been set.  For example, this harmless message appears when VS.NET loads the CLR (typically when you open a new managed project).

If you run into other violations reported by the probes that you don’t think are your fault, let me know.

Comments (16)

  1. Sam Gentile says:

    Adam, this tool rocks! I installed it and ran it on one of my Interop code pieces – a MC++ port of the Direct3D Windowed mode that uses IJW from MC++ WinForms to Direct/X. See the post on my link above, I’ll recomend this in my two Interop talks at Win-Dev. Thanks!

  2. Holy crap-ola — this thing rocks…

    I was just day-dreaming about how something like this would be useful this morning on the way to work…

    Too bad gotdotnet is hurting right now :(

  3. Kannan says:

    Adam, this is cool thing, but for now I’m not able to access the link in your post on gotdotnet as it gives me a 404. Anyway, thanks for the cool stuff.

  4. Adam Nathan says:

    I’m glad people are finding this useful! Kannan, gotdotnet.com was briefly unavailable this morning, but if you try the link again you should be able to download the tool.

  5. Frank Hileman says:

    Nice tool, but the bottom two group boxes on the form are not visible on my XP machine. I suspect this is because I use extra large fonts and the large size DPI setting. And the form cannot be resized, so there is no way to get to those buttons without editing your source code.

  6. Adam Nathan says:

    Thanks, Frank. I’ll be sure to address that in a future version of the tool.

  7. In a previous post I described how the Loader Log can be used to help diagnose problems such as assembly…

  8. rape stories says:

    Best of the text i read about a problem.

  9. gay rape says:

    We are wellocme to it’s configuration.

  10. <a href=’http://www.yahoo.com‘></a> http://www.insurance-top.com/auto/”>http://www.insurance-top.com/auto/ <a href=’http://www.insurance-top.com‘>auto insurance</a>. <a href="http://www.insurance-top.com ">Insurance car</a>: The autos insurance company, compare car insurance, auto insurance. [url]http://www.insurance-top.com/car/[/url] [link=http://www.insurance-top.com]insurance quote[/link] from site .

  11. http://www.insurance-top.com/company/ auto site insurance. The autos insurance company, compare car insurance, auto insurance. from website .

  12. http://www.insurance-top.com/company/”>http://www.insurance-top.com/company/ auto site insurance. [URL=http://www.insurance-top.com]home insurance[/URL]: The autos insurance company, compare car insurance, auto insurance. [url=http://www.insurance-top.com]cars insurance[/url] from website .

  13. http://www.insurance-top.com/company/ car site insurance. The autos insurance company, compare car insurance, auto insurance. from website .