Glimpse for Silverlight – Viewing Exceptions and Binding Errors

GlimpseOnLoad

Introduction

After my previous blog post, “Troubleshoot Silverlight 3 Data Bindings” I got some feedback and while in Phoenix I upgraded the code and have decided to call this Glimpse.

This initial release of Glimpse is a proof of concept project.  As I spend more time working with Silverlight 3, I’ll add more instrumentation views (Mole for Silverlight anyone?)

What is cool about Glimpse is that it can be used for local debug or deployed release builds.  It takes a single line of code to crank it up.

BTW:  I have not had a chance to make the UI pretty in Blend yet.  So go easy on Karl’s Moletones UI.

Glimpse Viewer Control

The Glimpse Viewer Control is hosted inside a Floatable WindowTim Heuer has a great post on how he modifed the default Silverlight ChildWindow so that it can be modal or non-modal.

I took Tim’s implementation and added the ability to set the location of the Floatable Window.  My code is in the Download section below.

Launching Glimpse

GlimpseLaunching

Glimpse is launched with a single line of code, passing the Application object and a string name for the Silverlight control.  If you have more that one Silverlight control on a web page, the name helps to know what control that Glimpse is providing information for.

In the above code, I’m testing if the current build is a DEBUG build. If so, launch Glimpse.  In your applications you can use other techniques for determining if Glimpse should be launched.

If your MainPage object throws an exception during object construction, Glimpse will display an Exception Viewer that will show you the exception and any inner exceptions.

To demonstrate this feature, you can uncomment the code in the MainPage constructor and then run the demo application.

GlimpseObjectConstructionException

Load Exception Viewer

The above code has outer and inner exceptions.  This viewer will display the outer exception and all nested inner exceptions.

GlimpseExceptionViewer

Application Unhandled Exceptions

When your Silverlight application has an application unhandled exception, the Glimpse Viewer Control will display a red ellipse on the right with a number indicating the number of unhandled exceptions.

  • Click the Expand button to display the Glimpse Viewer information
  • To return to contracted mode, click the Contract button
  • To clear the list of exceptions, click the Clear Exceptions button

GlimpseControlUnhandledExceptionNotification

GlimpseUnhandledException

Data Binding Exceptions

When your Silverlight application has an binding validation exception, the Glimpse Viewer Control will display a red ellipse on the left with a number indicating the number of exceptions.

In the below image, the Birthday field has text that can’t be converted into a date.

GlimpseDataBindingException

Pressing the Expand button displays the data binding validation exception.  This will also show any inner exceptions if they are present.

Notice the (Added) text on the left and field on the right.  This is the ValidationErrorEventAction property for the ValidationError.  When the validation error is cleared, the text will display “(Removed)”.

GlimpseDataBindingExceptionDetial

Bindings with no Source

The below image shows the Path with a typo, an “x” has been added to the correct property name “FirstName”.  This will cause a binding failure.

GlimpseNoBindingXAML

The below viewer provide information on all broken bindings in the host Silverlight control.  Binding errors are resolved each time the “Bindings with no Source” tab is selected.

GlimpseNoBindings

From Here

I have two projects that I want to launch on my blog, then I’ll take any feedback and add more views to the Glimpse Viewer Control.

What is nice about this approach is that you can launch Glimpse on a deployed production Silverlight control that needs some debugging love on a remote server in addition to using it during Silverlight control development.

Downloads

After downloading the below project, you must change the file extension from .doc to .zip, this is a requirement of WordPress.com.

Glimpse Control and Demo Project (61KB)

Karl’s Floatable Window  (22KB)

Have a great day,

Just a grain of sand on the worlds beaches.

7 Responses to Glimpse for Silverlight – Viewing Exceptions and Binding Errors

  1. mcomeaus2s says:

    Hey karl, i’ve translated the project to C#, mail me at mcomeau@ship2save.com if you’re interested in offering it. Nice Tool, i just love it.

    • Thanks for the heads up.

      Since your comment is at the head of the class, if I leave it here, others can inquire.

      Better, put it on a sky drive or similar place that files are left for downloading, then add a comment here and provide the link. I can then remove the above command with the email.

      Cheers,

      Karl

  2. tommckearney says:

    The code does not compile as is. With the Silverlight 3 SDK, the System.ComponentModel assembly no longer exists. Any chance of a code update?

    • I’ll look into this later today. Thanks for reporting this.

      Cheers,

      Karl

      • tommckearney says:

        No problem. I really appreciate the effort. If I weren’t in the middle of a tough deadline, I’d try to fix it myself.

        Tom

    • Tom,

      I just opened the project and didn’t have any problems compiling the applicaiton.

      I have the SL 3 SDK and Toolkit installed with no issues.

      The system componentmodel namespace is spread across several assemblies in SL.

      Not sure why you are seeing a compiler error.

      Can you post the stack trace?

      Cheers,

      Karl

  3. […] Glimpse for Silverlight – Viewing Exceptions and Binding Errors […]

Follow

Get every new post delivered to your Inbox.

Join 248 other followers