如何让 Silverlight 应用程序检查更新并要求用户升级?

发布于 2024-09-05 16:13:16 字数 2533 浏览 3 评论 0原文

我制作了一个浏览器外的 silverlight 应用程序,每次有新的 .xap 文件上传到该应用程序时,我希望该应用程序自动更新服务器。

当用户右键单击应用程序并单击更新时,默认设置为“检查更新,但让我选择是否下载并安装它们”:

< a href="https://i.sstatic.net/p1RCo.png" rel="nofollow noreferrer">替代文本
(来源:deviantsart.com

这让我相信可以让我的 Silverlight 应用程序自动检测服务器上是否存在新的 .xap 文件,如果存在,Silverlight 客户端会自动询问用户是否想要安装它。

  • 然而事实并非如此。我上传了一个新的 .xap 文件,但 Silverlight 应用程序不执行任何操作

  • 即使我将其添加到我的 App.xaml.cs

-

private void Application_Startup(object sender, StartupEventArgs e)
{
    this.RootVisual = new BaseApp();
    if (Application.Current.IsRunningOutOfBrowser)
    {
        Application.Current.CheckAndDownloadUpdateAsync();
    }
}

并且更新 .xap 文件时,Silverlight 应用程序不执行任何操作

  • 这个information 使我能够检查是否有更新,如果有,则告诉用户重新启动应用程序,但是当他重新启动应用程序时,什么也没有发生

--

private void Application_Startup(object sender, StartupEventArgs e)
{
    this.RootVisual = new BaseApp();
    if (Application.Current.IsRunningOutOfBrowser)
    {
        Application.Current.CheckAndDownloadUpdateAsync();
        Application.Current.CheckAndDownloadUpdateCompleted += new CheckAndDownloadUpdateCompletedEventHandler(Current_CheckAndDownloadUpdateCompleted);
    }
}

void Current_CheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e)
{
    if (e.UpdateAvailable)
    {
        MessageBox.Show("An application update has been downloaded. " +
            "Restart the application to run 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. " +
            "Visit the application home page to upgrade.");
    }
    else
    {
        //no new version available
    }
}

如何做我让我的 Silverlight 应用程序在每次启动时检查是否有新的 .xap 文件,如果有,则将控制权传递给 Silverlight 客户端以询问用户是否要下载它,正如上面的对话所暗示的那样?

I have made an out-of-browser silverlight application which I want to automatically update every time there is a new .xap file uploaded to the server.

When the user right-clicks the application and clicks on Updates, the default is set to "Check for updates, but let me choose whether to download and install them":

alt text
(source: deviantsart.com)

This leads me to believe that it is possible to make my Silverlight application automatically detect if there is a new .xap file present on the server, and if there is, the Silverlight client will automatically ask the user if he would like to install it.

  • This however is not the case. I upload a new .xap file and the Silverlight application does nothing.

  • Even if I add this to my App.xaml.cs:

--

private void Application_Startup(object sender, StartupEventArgs e)
{
    this.RootVisual = new BaseApp();
    if (Application.Current.IsRunningOutOfBrowser)
    {
        Application.Current.CheckAndDownloadUpdateAsync();
    }
}

and update the .xap file, the Silverlight application does nothing.

  • This information enabled me to check if there is an update and if so, tell the user to restart the application, but when he restarts the application, nothing happens:

--

private void Application_Startup(object sender, StartupEventArgs e)
{
    this.RootVisual = new BaseApp();
    if (Application.Current.IsRunningOutOfBrowser)
    {
        Application.Current.CheckAndDownloadUpdateAsync();
        Application.Current.CheckAndDownloadUpdateCompleted += new CheckAndDownloadUpdateCompletedEventHandler(Current_CheckAndDownloadUpdateCompleted);
    }
}

void Current_CheckAndDownloadUpdateCompleted(object sender, CheckAndDownloadUpdateCompletedEventArgs e)
{
    if (e.UpdateAvailable)
    {
        MessageBox.Show("An application update has been downloaded. " +
            "Restart the application to run 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. " +
            "Visit the application home page to upgrade.");
    }
    else
    {
        //no new version available
    }
}

How do I make my Silverlight application check, each time it starts, if there is a new .xap file, and if there is, pass control to the Silverlight client to ask the user if he wants to download it, as the above dialogue implies is possible?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

请帮我爱他 2024-09-12 16:13:16

第一个对话框是关于如何安装 Silverlight 本身的更新,与您的应用程序无关。

使用 CheckAndDownloadUpdateAsync 应自动下载新的 XAP。根据文档,没有办法阻止您调用 CheckAndDownloadUpdateAsync 来安装新版本。

The first dialog is about how updates to Silverlight itself are installed and has nothing to do with your application.

Using the CheckAndDownloadUpdateAsync the new XAP should be downloaded automatically. Acording to the doc there is no way to prevent the new version from being installed one you call CheckAndDownloadUpdateAsync.

温折酒 2024-09-12 16:13:16

您所指的屏幕并不特定于任何 silverlight 应用程序。它指的是 silverlight 插件本身。

CheckAndDownloadUpdateAsync 方法应该已下载较新的版本,但用户需要重新启动应用程序才能开始使用新应用程序。您可以使用已完成事件中事件参数的 UpdateAvailable 属性来确定是否要求用户重新启动。

The screen you are refering to the is not specific to any silverlight application. Its refering to the silverlight plugin itself.

The CheckAndDownloadUpdateAsync method should have downloaded the newer version but the user will need to restart the application in order to start using the new application. You use the UpdateAvailable property of the event args in the completed event to determine whether to ask the user to restart.

尛丟丟 2024-09-12 16:13:16

通过合并外部版本控制检查,您可能会得到您想要的东西。查看安装的版本和服务器上的版本是否不同。

如果不同,请询问用户是否要更新。如果他们选择“是”,则调用 CheckAndDownloadUpdateAsync();

否则,如果他们选择“否”或版本相同,则跳过它。

有很多方法可以进行您自己的版本控制检查。包括在构建时填充的静态只读属性,这些属性在 http 请求上具有某种类似的结果。

您可以使用 Web 客户端从服务器获取响应,并将其与当前加载的应用程序版本进行比较。

您可以在回调中合并一个方法来显示一条消息,告诉用户重新启动应用程序。

You might get what you're wanting by incorporating an external version control check. have it look to see if the version that's installed and the version on the server is different.

If it's different ask the user if they want to update. If they choose yes, then invoke CheckAndDownloadUpdateAsync();

otherwise skip it if they choose no or if the version is the same.

there are many ways to do your own versioning checks. Including static readonly properties that are populated @ build time and have some kind of similar result on an http request.

You could use the webclient to grab a response from the server and compare that with the currently loaded version of the application.

You can incorporate a method on the callback to go to show a message that tells the user to restart the app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文