Updated: September 2010
Launches an asynchronous process to check for and download an updated version of the application.
Assembly: System.Windows (in System.Windows.dll)
Handle the CheckAndDownloadUpdateCompleted event to receive notification when the application has finished checking for an update. In the event handler, the UpdateAvailable property is true if a newer version of the application was discovered and successfully downloaded. In this case, you can alert the user to restart the application in order to load the update.
If an application update is available, but uses a newer version of Silverlight that the user has not yet installed, the update will not be downloaded. This also occurs if an update changes the application to require elevated trust. In both cases, the UpdateAvailable property value is false, and the Error property value is an Exception instance. With a Silverlight version change, the exception is a PlatformNotSupportedException instance. With a security change, the exception is a SecurityException instance. When this happens, you can alert the user to open the application's host Web site, triggering your HTML-based Silverlight upgrade experience.
In general, you should check for updates only with the consent of the user, and notify the user when an update is available.
The OutOfBrowserSettings.ShortName value must remain the same across multiple versions of an application for the update mechanism to work correctly.
The following code example demonstrates how to use this method. This example is part of a larger example available in How to: Implement Offline Support for Out-of-Browser Applications.
Private WithEvents app As Application = Application.Current ... Private Sub updateButton_Click(ByVal sender As Object, _ ByVal e As RoutedEventArgs) app.CheckAndDownloadUpdateAsync() End Sub Private Sub App_CheckAndDownloadUpdateCompleted(ByVal sender As Object, _ ByVal e As CheckAndDownloadUpdateCompletedEventArgs) _ Handles app.CheckAndDownloadUpdateCompleted If e.UpdateAvailable Then MessageBox.Show("An application update has been downloaded. " & _ "Restart the application to run the new version.") ElseIf e.Error IsNot Nothing Then MessageBox.Show( _ "An application update is available, but an error has occurred.\n" & _ "This can happen, for example, when the update requires\n" & _ "a new version of Silverlight or requires elevated trust.\n" & _ "To install the update, visit the application home page.") LogErrorToServer(e.Error) Else MessageBox.Show("There is no update available.") End If End Sub Private Sub LogErrorToServer(ByRef ex As Exception) ' Not implemented. Logging the exact error to the server can help ' diagnose any problems that are not resolved by the user reinstalling ' the application from its home page. End Sub
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.