Update Out Of Browser (OOB) Silverlight apps

Once your Silverlight application installed on the local computer what happens if there is an update ?

The local application is not updated automatically but you can check that in your code. The CheckAndDownloadUpdateAsync() method downloads the updated application if available and you can notify the user.

I put this code in the constructor of the App:

App.xaml.cs:

public App()
{
    this.Startup += this.Application_Startup;
    this.UnhandledException += this.Application_UnhandledException;

    InitializeComponent();

    if (Application.Current.IsRunningOutOfBrowser)
    {
        App.Current.CheckAndDownloadUpdateCompleted += 
new CheckAndDownloadUpdateCompletedEventHandler(CheckAndDownloadUpdateCompleted); App.Current.CheckAndDownloadUpdateAsync(); } } void CheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e) { if (e.Error == null && e.UpdateAvailable) { MessageBox.Show("Application updated, please restart to apply changes."); } }

Some points to mention:

  • By default OOB do not automatically check for update.
  • Use CheckAndDownloadUpdateAsync() method which check, download and install updates for you.
  • There is no way to separate the Check from the Download…

Technorati Tags:

No Comments