C#使用 AutoUpdater.NET 实现程序自动更新

写在前面

开发桌面应用程序的时候,经常会因为新增功能需求或修复已知问题,要求客户更新应用程序,为了更好的服务客户,通常会在程序启动时判断版本变更情况,如发现新版本则自动弹出更新对话框,提醒客户更新成最新版本。在.Net体系中采用 AutoUpdater.NET 组件可以非常便捷的实现这一功能。

老规矩从NuGet获取 AutoUpdater.NET 组件:

参考官方示例

代码实现

新建WinForm示例程序,主要代码如下:

cs 复制代码
namespace AutoUpdaterWinFormsApp
{
    using AutoUpdaterDotNET;

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            AutoUpdater.InstalledVersion = new Version("1.2");
            System.Timers.Timer timer = new System.Timers.Timer
            {
                Interval = 1 * 30 * 1000,
                SynchronizingObject = this
            };
            timer.Elapsed += delegate
            {
                AutoUpdater.Start("https://rbsoft.org/updates/AutoUpdaterTest.xml");
            };
            timer.Start();
        }
    }
}

xml配置:

XML 复制代码
<?xml version="1.0" encoding="UTF-8"?>
<item>
	<version>2.0.0.0</version>
	<url>https://rbsoft.org/downloads/AutoUpdaterTest.zip</url>
	<changelog>https://github.com/ravibpatel/AutoUpdater.NET/releases</changelog>
	<mandatory>false</mandatory>
</item>

调用示例

相关推荐
源代码•宸1 天前
Golang语法进阶(协程池、反射)
开发语言·经验分享·后端·算法·golang·反射·协程池
basketball6161 天前
python 的对象序列化
开发语言·python
fie88891 天前
钢结构件制造车间生产调度实例:MATLAB实现(基于遗传算法)
开发语言·matlab·制造
沐知全栈开发1 天前
PHP 安装指南
开发语言
Highcharts.js1 天前
Highcharts Grid 表格/网格安装 |官方安装文档说明
开发语言·javascript·表格组件·highcharts·官方文档·安装说明·网格组件
Coder_Boy_1 天前
基于SpringAI的在线考试系统-企业级软件研发工程应用规范实现细节
大数据·开发语言·人工智能·spring boot
lly2024061 天前
SQL SELECT 语句详解
开发语言
superman超哥1 天前
Rust 异步时间管理核心:Tokio 定时器实现机制深度剖析
开发语言·rust·编程语言·rust异步时间管理核心·tokio定时器实现机制·tokio定时器
朔北之忘 Clancy1 天前
2025 年 9 月青少年软编等考 C 语言一级真题解析
c语言·开发语言·c++·学习·数学·青少年编程·题解
玛丽莲茼蒿1 天前
javaSE 集合框架(五)——java 8新品Stream类
java·开发语言