2

我有一些用户正在使用 Silverlight 应用程序,但在发布新版本时没有收到更新。这不是假设是自动的,还是我在某处错过了一个选项?我也开始认为 XAP 文件可能被缓存了,我需要防止这种情况发生。

有什么想法吗?

4

2 回答 2

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.");
        }
    }
于 2010-01-15T04:07:22.693 回答
1

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

于 2010-01-15T04:06:10.287 回答