有没有办法检查ClickOnce应用程序是否正在运行最新版本 [英] Is there a way to check if a ClickOnce application is running the latest version

查看:99
本文介绍了有没有办法检查ClickOnce应用程序是否正在运行最新版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解ClickOnce应用程序可以自动更新。
但是,微软提供的选项不是我想要的。



如果在应用程序启动之前检查版本,则启动速度会变慢。 / p>

如果我在应用程序启动后检查该版本,我不知道在下一次启动之前是否有可用的新版本。



我正在寻找一个布尔函数来检查是否有新版本。这将使我向用户建议重新启动应用程序。

解决方案

 使用系统.Deployment.Application; 

public bool IsUpdateAvailable()
{
if(!ApplicationDeployment.IsNetworkDeployed)返回false;

返回ApplicationDeployment.CurrentDeployment.CheckForUpdate();
}

当然,您可能希望通过按钮并换行来访问此功能某些用户界面,像这样


I understand that ClickOnce applications can update automatically. However, the options offered by Microsoft are not what I am looking for.

If I check the version before the application starts, the startup is slower.

If I chek the version after the application starts, I don't know than a new version is available until the next startup.

I am looking for a boolean function to check if a new version is available. This would enable me to suggest to the user to restart the application.

解决方案

using System.Deployment.Application;

public bool IsUpdateAvailable()
{
    if (!ApplicationDeployment.IsNetworkDeployed) return false;

    return ApplicationDeployment.CurrentDeployment.CheckForUpdate();         
}

Of course, you might want to make this feature accessible via a button and wrap some UI around it, like this.

这篇关于有没有办法检查ClickOnce应用程序是否正在运行最新版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆