Silverlight 3超出浏览器更新

时间:2009-08-11 17:17:21

标签: silverlight silverlight-3.0 auto-update out-of-browser

我有一些使用Silverlight应用的用户在发布新版本时没有收到更新。难道这不是自动的,或者我在某个地方错过了选项吗?我也开始认为可能是缓存了XAP文件而我有些需要防止这种情况。

有什么想法吗?

2 个答案:

答案 0 :(得分:5)

您需要编写几行代码。

如果您熟悉“一键式”部署,那么Silverlight中不存在您曾经使用过的一些选项。你需要自己编写代码。

http://nerddawg.blogspot.com/2009/07/silverlight-out-of-browser-apps-how.html

    private void Application_Startup(object sender, StartupEventArgs e)
    {
        this.RootVisual = new MainPage();

        if (Application.Current.IsRunningOutOfBrowser)
        {
            Application.Current.CheckAndDownloadUpdateAsync();
        }

然后在你的App()构造函数中:

    Application.Current.CheckAndDownloadUpdateCompleted += 
    new CheckAndDownloadUpdateCompletedEventHandler(Current_CheckAndDownloadUpdateCompleted);

和一个事件处理程序:

 void Current_CheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e)
    {
        // http://nerddawg.blogspot.com/2009/07/silverlight-out-of-browser-apps-how.html
        if (e.UpdateAvailable)
        {
            MessageBox.Show("The application has been updated! Please close and reopen it to load the new version.");
        }
        else if (e.Error != null && e.Error is PlatformNotSupportedException)
        {
            MessageBox.Show("An application update is available, " +
                "but it requires a new version of Silverlight. " +
                "Please contact tech support for further instructions.");
        }
    }

答案 1 :(得分:1)

如果开发人员执行CheckAndDownloadUpdateAsync()调用,它只会自动更新。查看更新:http://timheuer.com/blog/archive/2009/07/10/silverlight-3-released-what-is-new-and-changed.aspx#oob