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 Window. Tim 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.
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.
Load Exception Viewer
The above code has outer and inner exceptions. This viewer will display the outer exception and all nested inner exceptions.
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
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.
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)”.
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.
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.
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.
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