4

When a Silverlight 4 application is installed and run out-of-browser (OOB), is it possible to have the application automatically recognize updates to the .xap file (and either automatically install or prompt the user to update)?

If you access the application from it's original web URL, you are automatically given the latest & greatest (based on your settings).

But once I install the application to run OOB, it does not seem to recognize updates to the original .xap file, nor does there seem to be any way to trigger an update (outside of right-clicking, uninstalling, and then going out to the website to get the latest version).

Thanks in advance

enforge
  • 915
  • 3
  • 10
  • 26

2 Answers2

3

This is something your application needs to implement. However the Application object provides a simple means to acheive this via the CheckAndDownloadUpdateAsync method.

AnthonyWJones
  • 187,081
  • 35
  • 232
  • 306
3

Additional information for others looking at the CheckAndDownloadUpdateAsync method not finding an update. Ensure you have signed your xap file.

"SL Project"->Properties->Signing->Check "Sign the Xap File"

Also CheckAndDownloadUpdateAsync seemed to block the UI thread when placed in the Application_Startup() as many samples suggest. Placing it in a background worker was less disruptive and allowed us to customize the frequency of the check.

Update: I am not sure if CheckAndDownladUpdateAsync still behaves the same with SL5. This is how I did it with SL4:

I wrapped any code that needs the UI thread with Dispatcher.BeginInvoke() including:

Deployment.Current.Dispatcher.BeginInvoke(() =>
{
  App.Current.CheckAndDownloadUpdateCompleted += new CheckAndDownloadUpdateCompletedEventHandler(App_CheckAndDownloadUpdateCompleted);
  App.Current.CheckAndDownloadUpdateAsync();
}
Fares
  • 669
  • 6
  • 11
  • Could you provide a sample of how you integrated the backgroundworker and CheckAndDownloadUpdateAsync()? I'm getting a invalid cross thread exception when I try to do it your way... – rumblefx0 Nov 23 '12 at 08:50
  • This was used with SL4, I am not sure if it still applies to SL5. I wrapped any code that needs the UI thread with Dispatcher.BeginInvoke(). Including: App.Current.CheckAndDownloadUpdateCompleted += new CheckAndDownloadUpdateCompletedEventHandler(App_CheckAndDownloadUpdateCompleted); App.Current.CheckAndDownloadUpdateAsync(); – Fares Dec 19 '12 at 17:05