Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Tagged as

Glimpse for Silverlight – Viewing Exceptions and Binding Errors

, 19 Jul 2009 CPOL
Rate this:
Please Sign up or sign in to vote.
IntroductionAfter 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 wit

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.

Posted in CodeProject, Data Binding, Exceptions, Silverlight, VB.NET

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Karl Shifflett
Architect Gayle Manufacturing Company
United States United States
Karl loves .NET, WPF, WCF, ASP.NET, VB.NET and C#.
 
Awards:
 
  • December 2008 VB.NET Code Project Article Award
  • 2009 Code Project MVP
  • 2008 Code Project MVP
  • 2008 Microsoft MVP - Client App Dev
  • December 2007 VB.NET Code Project Article Award
  • Gold Medal Winner at IBM's 1998 PROIV Programming Contest in Las Vegas
Click here to check out my Blog
 
Click here to learn about Mole 2010 debugging tool for Visual Studio 2010
 
Click here to read about XAML Power Toys
 

Just a grain of sand on the worlds beaches.

Follow on   Twitter

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.1411019.1 | Last Updated 19 Jul 2009
Article Copyright 2009 by Karl Shifflett
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid