Share via


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

  • Anonymous
    May 13, 2003
    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!
  • Anonymous
    May 13, 2003
    The comment has been removed
  • Anonymous
    May 13, 2003
    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.
  • Anonymous
    May 13, 2003
    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.
  • Anonymous
    May 22, 2003
    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.
  • Anonymous
    May 25, 2003
    Thanks, Frank. I'll be sure to address that in a future version of the tool.
  • Anonymous
    July 27, 2004
    The comment has been removed
  • Anonymous
    July 27, 2004
    The comment has been removed
  • Anonymous
    June 22, 2005
    In a previous post I described how the Loader Log can be used to help diagnose problems such as assembly...
  • Anonymous
    May 31, 2006
    Best of the text i read about a problem.
  • Anonymous
    June 02, 2006
    We are wellocme to it's configuration.
  • Anonymous
    June 19, 2006
    <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 .
  • Anonymous
    June 19, 2006
    http://www.insurance-top.com/company/ auto site insurance. The autos insurance company, compare car insurance, auto insurance. from website .
  • Anonymous
    June 19, 2006
    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 .
  • Anonymous
    June 20, 2006
    http://www.insurance-top.com/company/ car site insurance. The autos insurance company, compare car insurance, auto insurance. from website .
  • Anonymous
    August 10, 2006
    autoinsurance <a href=http://autoinsurance.ibusinessdot.com/>autoinsurance</a>