Overview

There are two types of errors that occur in Silverlight applications. Synchronous method calls will throw an error while the method is being called, but asynchronous errors can be thrown at anytime. Synchronous errors are normally handled by placing a try/catch block around the method call and asynchronous by attaching an event handler to the respective error event. A global level OnError event handler is called for both cases when an error is not handled by either a try/catch block or error event handler.

Global OnError Event

Silverlight will display a standard alert message box by default with some information about the error if a custom OnError event handler is not specified. You should try to handle errors at the most granular level possible for the best user experience. You can also specify a custom OnError event handler for unhandled errors when the Silverlight plug-in is embedded.

Common Error Events

Downloader

The Downloader object has a DownloadFailed event which is raised when the requested content fails to load. You can check the Status and StatusText properties on the Downloader object for additional information.

Image & ImageBrush

The Image and ImageBrush objects have an ImageFailed event which is raised when the requested image fails to load or is in an incorrect format.

MediaElement

The MediaElement object has a MediaFailed event which is raised when the requested content fails to load, is in an incorrect format, or an unknown playback error occurs.

Further Reading

Related information on the web is listed below.