views:

189

answers:

2

I'm wondering how to setup my Silverlight project to enable automatic updates for out-of-browser application.

I added some code in app.xaml.cs (see below), rebuild app, installed as out-of-browser, changed versionionfo in asseblyinfo.cs, rebuilded, run again but unfortunatelly no update happened. Am I still missing something?

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

        InitializeComponent();

        if (Application.Current.IsRunningOutOfBrowser)
        {
            App.Current.CheckAndDownloadUpdateCompleted +=
                new CheckAndDownloadUpdateCompletedEventHandler(App_CheckAndDownloadUpdateCompleted);
            App.Current.CheckAndDownloadUpdateAsync();
        }
    }

    void App_CheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e)
    {
        if (e.Error == null && e.UpdateAvailable)
        {
            MessageBox.Show("Application updated, please restart to apply changes.");
        }
    }

EDIT

Bonus question:

How App detect that there is an update? From assemblyinfo.cs? Somewhere in manifests?

EDIT

Can anybody explain me WHY IsRunningOutOfBrowser returns always FALSE even if App is run from desktop's shortcut?

A: 

Make sure the web server was running so the client can connect to the server and check for updates. You might also want to check the Error property to see if there where any exceptions.

Maurice
+1  A: 

Thanks to Silvelright forum, there is a solution.

IsOutOfBrowser property cannot be used in constructor. The time where it starts working is Application started event.

tomo