Up Silverlight tour
DevForce Resource Center » Getting started » Silverlight tour » Tour of DevForce Silverlight - Part 5

Tour of DevForce Silverlight - Part 5

Last modified on November 06, 2012 13:10

Part 5: Coping with Trouble - In Part 5 of this series we'll work with the application from Part 4 to add error handling.

This video was recorded using DevForce 2010. Download the sample code below for updated techniques in DevForce 2012.



The DebugLog

When stuff happens one of the first things you should do is look at the DevForce DebugLog.  DevForce always generates tracing messages as it runs, and by default writes those messages on the EntityServer to a file named DevForceDebugLog.xml.  When a problem occurs in your application, the messages in the log can often help to diagnose the problem.

As shown during the video, if we introduce an error (here we modified the database connection string) a message will be recorded in the log file indicating the problem:

dberror.JPG

Add error handling

Every application should have error handling, and we've been remiss in not adding it earlier.  When using asynchronous queries and saves in the task-based asynchronous API, we can add a try/catch to handle the problem, just as we would with synchronous operations.  

C#
try {
   var results = await query.ExecuteAsync();
   results.ForEach(Employees.Add);
   CurrentEmployee = Employees.FirstOrDefault();
} catch (Exception e) {
  throw new InvalidOperationException("Query failed: " + e.Message);
}
VB
Try
  Dim results = Await query.ExecuteAsync()
   results.ForEach(Sub(emp) Employees.Add(emp))
   CurrentEmployee = Employees.FirstOrDefault
Catch e As Exception
  Throw New InvalidOperationException("Query failed: " + Convert.ToString(e.Message))
End Try

Learn More

Here are some links for more detail on what we've covered here, and additional information we hope you find useful.

Prerequisites

The user interface for the application built during this tour uses a DataForm component supplied by the Silverlight 5 Toolkit (different from the Silverlight 5 Tools!). You can download the Toolkit here:

http://silverlight.codeplex.com/


Created by DevForce on May 11, 2011 17:34

This wiki is licensed under a Creative Commons 2.0 license. XWiki Enterprise 3.2 - Documentation. Copyright © 2020 IdeaBlade