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.

Published 13 May 03 01:24 by Adam Nathan
Filed under:

Comments

# Sam Gentile said on May 13, 2003 8:58 AM:
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!
# Ethan J. Brown said on May 13, 2003 11:11 AM:
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 :(
# Kannan said on May 13, 2003 11:41 AM:
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.
# Adam Nathan said on May 13, 2003 4:19 PM:
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.
# Frank Hileman said on May 22, 2003 5:23 PM:
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.
# Adam Nathan said on May 25, 2003 10:41 PM:
Thanks, Frank. I'll be sure to address that in a future version of the tool.
# Sex Girl BBS said on July 27, 2004 11:25 AM:
Sex Girl BBS
http://www.dd20.com
Sex Girl News
http://www.waxw.com
Girl Music
http://music.dd20.com
# Sex Girl BBS said on July 27, 2004 11:25 AM:
Sex Girl BBS
http://www.dd20.com
Sex Girl News
http://www.waxw.com
Girl Music
http://music.dd20.com
# Steven Pratschner's .Net CF WebLog said on June 22, 2005 11:48 AM:
In a previous post I described how the Loader Log can be used to help diagnose problems such as assembly...
# rape stories said on June 1, 2006 3:17 AM:
Best of the text i read about a problem.
# gay rape said on June 2, 2006 6:59 PM:
We are wellocme to it's configuration.
# car insurance said on June 19, 2006 3:08 PM:
<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 .
# insurance auto said on June 19, 2006 3:09 PM:
http://www.insurance-top.com/company/ auto site insurance. The autos insurance company, compare car insurance, auto insurance. from website .
# insurance auto said on June 19, 2006 3:10 PM:
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 .
# insurance auto said on June 21, 2006 12:24 AM:
http://www.insurance-top.com/company/ car site insurance. The autos insurance company, compare car insurance, auto insurance. from website .
# autoinsurance said on August 10, 2006 12:35 PM:
autoinsurance <a href=http://autoinsurance.ibusinessdot.com/>autoinsurance</a>
New Comments to this post are disabled
Page view tracker