如何让我的C#应用​​程序检查更新?

时间:2021-02-14 07:14:56

I am building a C# windows application. I want it so whenever I click the update button in my form the application will Start looking for whether there is a new version avaliable on my Server.

我正在构建一个C#windows应用程序。我想要它,所以每当我点击我的表单中的更新按钮时,应用程序将开始查找我的服务器上是否有新版本可用。

If there is then proceed to update the Software.

如果有,则继续更新软件。

How is this usually handled?

这通常如何处理?

4 个解决方案

#1


Take a look at Click Once. This thread might also make an interesting read.

看看Click Once。这个帖子也可能会有趣的阅读。

#2


Let me start by saying we offer a complete updating solution which includes:

首先我要说的是我们提供完整的更新解决方案,其中包括:

wyUpdate handles all of the Vista/Windows 7 UAC problems and all the file permission problems that inevitably pop up when you're trying to update complex software.

wyUpdate处理所有Vista / Windows 7 UAC问题以及当您尝试更新复杂软件时不可避免地出现的所有文件权限问题。

That being said, if you want to build your own updater here are some tips:

话虽这么说,如果你想在这里建立自己的更新程序是一些提示:

Building your own updater

A good place to start is the wyUpdate C# source code I mentioned above. You can cannibalize it and use it for your own purposes. Some of the algorithms it contains:

一个好的起点是我上面提到的wyUpdate C#源代码。您可以蚕食它并将其用于您自己的目的。它包含的一些算法:

  • Full Windows Vista / Windows 7 UAC support
  • 完整的Windows Vista / Windows 7 UAC支持

  • Ability for limited users to check and then update if they have credentials
  • 限制用户能够检查,然后更新,如果他们有凭据

  • Support for wonky corporate inernet. (If you've ever worked with a corporation this is a real problem).
  • 支持wonky公司inernet。 (如果你曾与公司合作过这是一个真正的问题)。

  • Quick extracting, patching, and installing of files.
  • 快速提取,修补和安装文件。

  • Registry support.
  • Roll back files & registry on error or cancellation by the user
  • 用户在错误或取消时回滚文件和注册表

  • Self-update (no files left behind)
  • 自我更新(没有留下文件)

We also have the file specifications here.

我们这里也有文件规范。

Automatic updating

Since being automatic is a requirement let me tell you how we do it with our AutomaticUpdater control.

由于是自动要求,让我告诉你我们如何使用我们的AutomaticUpdater控件。

We use named pipes to communicate between the standalone updater (wyUpdate) and the Automatic Updater control sitting on your program's form. wyUpdate reports progress to the Automatic Updater, and the Automatic Updater can tell wyUpdate to cancel progress, to start downloading, start extracting, etc.

我们使用命名管道在独立更新程序(wyUpdate)和程序表单上的自动更新程序控件之间进行通信。 wyUpdate向自动更新程序报告进度,自动更新程序可以告诉wyUpdate取消进度,开始下载,开始提取等。

This keeps the updater separate from your application.

这使更新程序与您的应用程序分开。

In fact, the exact named pipes C# code we use is included in an article I wrote a little while back: Multi-process C# app like Google Chrome.

实际上,我们使用的确切命名管道C#代码包含在我写的一篇文章中:像Google Chrome这样的多进程C#应用程序。

#3


If you want to app update automatically from a website and handle the code by yourself do following steps...

如果您想从网站自动更新应用程序并自行处理代码,请执行以下步骤...

  1. Create an XML file with a unique name for example help.xml and build a structure to specify list of files to be update in specific directories and version and etc the put it on your website...

    创建一个具有唯一名称的XML文件,例如help.xml,并构建一个结构,以指定要在特定目录和版本等中更新的文件列表,并将其放在您的网站上...

  2. App after connecting to website download this file and read content to make sure is any new files (update files) exist on website...

    应用程序连接到网站后下载此文件并阅读内容以确保网站上存在任何新文件(更新文件)...

  3. If a new version of files was exists so start downloading from url specified in help.xml file!

    如果存在新版本的文件,请从help.xml文件中指定的url开始下载!

#4


Other answers look great.

其他答案看起来很棒。

However, if you're looking to hand-roll your own for whatever reason, simply put an XML file with information you need for your update process (e.g. description and version number of currently available version) somewhere on a webserver and use an HttpWebRequest (or HttpWebClient?) to download this file and process like you would any XML.

但是,如果您因任何原因想要手动滚动自己,只需在Web服务器上的某处放置一个XML文件,其中包含您更新过程所需的信息(例如当前可用版本的描述和版本号),并使用HttpWebRequest(或HttpWebClient?)下载此文件和进程就像你任何XML一样。

I use this simple method in peSHIr Tweets and it works great. Just update this file after you put a new version online for download and your update check will find it. Anything about this process is changeable the way you like, as you wrote it yourself.

我在peSHIr推文中使用这个简单的方法,效果很好。在将新版本联机下载后,只需更新此文件,您的更新检查就会找到它。关于这个过程的任何事情都可以按你喜欢的方式改变,就像你自己写的一样。

Unless this is a private project for your own amusement/use/learning - like in my case - do look if anything already available suits your needs though!

除非这是一个私人项目供您自己娱乐/使用/学习 - 就像在我的情况下一样 - 看看有没有适合您的需求!

#1


Take a look at Click Once. This thread might also make an interesting read.

看看Click Once。这个帖子也可能会有趣的阅读。

#2


Let me start by saying we offer a complete updating solution which includes:

首先我要说的是我们提供完整的更新解决方案,其中包括:

wyUpdate handles all of the Vista/Windows 7 UAC problems and all the file permission problems that inevitably pop up when you're trying to update complex software.

wyUpdate处理所有Vista / Windows 7 UAC问题以及当您尝试更新复杂软件时不可避免地出现的所有文件权限问题。

That being said, if you want to build your own updater here are some tips:

话虽这么说,如果你想在这里建立自己的更新程序是一些提示:

Building your own updater

A good place to start is the wyUpdate C# source code I mentioned above. You can cannibalize it and use it for your own purposes. Some of the algorithms it contains:

一个好的起点是我上面提到的wyUpdate C#源代码。您可以蚕食它并将其用于您自己的目的。它包含的一些算法:

  • Full Windows Vista / Windows 7 UAC support
  • 完整的Windows Vista / Windows 7 UAC支持

  • Ability for limited users to check and then update if they have credentials
  • 限制用户能够检查,然后更新,如果他们有凭据

  • Support for wonky corporate inernet. (If you've ever worked with a corporation this is a real problem).
  • 支持wonky公司inernet。 (如果你曾与公司合作过这是一个真正的问题)。

  • Quick extracting, patching, and installing of files.
  • 快速提取,修补和安装文件。

  • Registry support.
  • Roll back files & registry on error or cancellation by the user
  • 用户在错误或取消时回滚文件和注册表

  • Self-update (no files left behind)
  • 自我更新(没有留下文件)

We also have the file specifications here.

我们这里也有文件规范。

Automatic updating

Since being automatic is a requirement let me tell you how we do it with our AutomaticUpdater control.

由于是自动要求,让我告诉你我们如何使用我们的AutomaticUpdater控件。

We use named pipes to communicate between the standalone updater (wyUpdate) and the Automatic Updater control sitting on your program's form. wyUpdate reports progress to the Automatic Updater, and the Automatic Updater can tell wyUpdate to cancel progress, to start downloading, start extracting, etc.

我们使用命名管道在独立更新程序(wyUpdate)和程序表单上的自动更新程序控件之间进行通信。 wyUpdate向自动更新程序报告进度,自动更新程序可以告诉wyUpdate取消进度,开始下载,开始提取等。

This keeps the updater separate from your application.

这使更新程序与您的应用程序分开。

In fact, the exact named pipes C# code we use is included in an article I wrote a little while back: Multi-process C# app like Google Chrome.

实际上,我们使用的确切命名管道C#代码包含在我写的一篇文章中:像Google Chrome这样的多进程C#应用程序。

#3


If you want to app update automatically from a website and handle the code by yourself do following steps...

如果您想从网站自动更新应用程序并自行处理代码,请执行以下步骤...

  1. Create an XML file with a unique name for example help.xml and build a structure to specify list of files to be update in specific directories and version and etc the put it on your website...

    创建一个具有唯一名称的XML文件,例如help.xml,并构建一个结构,以指定要在特定目录和版本等中更新的文件列表,并将其放在您的网站上...

  2. App after connecting to website download this file and read content to make sure is any new files (update files) exist on website...

    应用程序连接到网站后下载此文件并阅读内容以确保网站上存在任何新文件(更新文件)...

  3. If a new version of files was exists so start downloading from url specified in help.xml file!

    如果存在新版本的文件,请从help.xml文件中指定的url开始下载!

#4


Other answers look great.

其他答案看起来很棒。

However, if you're looking to hand-roll your own for whatever reason, simply put an XML file with information you need for your update process (e.g. description and version number of currently available version) somewhere on a webserver and use an HttpWebRequest (or HttpWebClient?) to download this file and process like you would any XML.

但是,如果您因任何原因想要手动滚动自己,只需在Web服务器上的某处放置一个XML文件,其中包含您更新过程所需的信息(例如当前可用版本的描述和版本号),并使用HttpWebRequest(或HttpWebClient?)下载此文件和进程就像你任何XML一样。

I use this simple method in peSHIr Tweets and it works great. Just update this file after you put a new version online for download and your update check will find it. Anything about this process is changeable the way you like, as you wrote it yourself.

我在peSHIr推文中使用这个简单的方法,效果很好。在将新版本联机下载后,只需更新此文件,您的更新检查就会找到它。关于这个过程的任何事情都可以按你喜欢的方式改变,就像你自己写的一样。

Unless this is a private project for your own amusement/use/learning - like in my case - do look if anything already available suits your needs though!

除非这是一个私人项目供您自己娱乐/使用/学习 - 就像在我的情况下一样 - 看看有没有适合您的需求!