我如何获得一个控制台应用程序来检查更新,而无需使用ClickOnce? [英] How do I get a console application to check for updates without using ClickOnce?

查看:152
本文介绍了我如何获得一个控制台应用程序来检查更新,而无需使用ClickOnce?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个正常的Windows应用程序,我可以使用...结果
System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CheckForUpdate()结果
... ...,以确定是否有可用的更新。

In a normal Windows application I can use...
System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CheckForUpdate()
...to determine whether or not there is an update available.

我知道我可以使用的System.Reflection 大会的AssemblyName 来打印应用程序的版本,因为它正在运行,但我不知道如何得到它来比较一下的出版最近。

I know I can use System.Reflection and Assembly and AssemblyName to print the version of the application as it is currently running, but I don't know how to get it to compare that to what's been published most recently.

什么是相当于的checkForUpdate()控制台应用程序,而无需使用的ClickOnce?

What is the equivalent to CheckForUpdate() for a console application, without using ClickOnce?

推荐答案

您将需要的东西服务器端应用程序可以用它来找到出的最新版本是什么。就个人而言,我会返回最新的版本号和URL在那里可以下载一个Web服务去的,但是这也可以与被解析此信息的静态页面完成。应用程序启动时,会检查它的版本号从服务返回的。如果服务报告的更新版本HttpWebRequest的使用(或其他方式)下载新版本。如果新版本打包为一个安装程序,你可以再执行安装程序并退出当前运行的实例。如果你想要的东西不是一个安装程序更加沉默,你需要的地方更新你的EXE的一种方式。这通常是由等待主应用程序退出,并给地方移动exe文件的新版本第2个应用程序(更新)完成,然后重新启动应用程序。有一点要记住的是,对于这个工作,该应用程序运行的需要有写权限的程序目录的用户。

You would need something server side that the application can use to find out what the most recent version is. Personally, I would go with a web service that returns the most recent version number and a url where it can be downloaded, but this could also be done with a static page that gets parsed for this information. The application starts up, checks it's version number to the one returned from the service. If the service reports a newer version use HttpWebRequest (or other method) to download the new version. If the new version is packaged as an installer you could then execute the installer and exit the currently running instance. If you want something more silent than an installer you will need a way of updating your exe in place. This is usually done by a 2nd application (the updater) that waits for the main application to exit and moves the new version of the exe in to place, then restarts the application. One thing to keep in mind is that for this to work the user that the application is running as will need to have permission to write to the program directory.

如果这是更要使用文件共享,你可以做不同的企业环境中。让程序检查一个众所周知的共享目录与最新版本的文本文件和路径的更新。解析的信息与上述相同的文本文件,并使用 system.io 命名空间的类从指定的路径抓住新版本。它基本上相同的操作,但使用文件路径,而不是Web请求。

If this is more of a corporate environment where you want to use fileshares you could do it differently. Have the program check a well known shared directory for a text file with the most recent version and the path to the update. Parse the text file for the information the same as above, and grab the new version from the specified path using the system.io namespace classes. It's basically the same operation, but using file paths instead of web requests.

这篇关于我如何获得一个控制台应用程序来检查更新,而无需使用ClickOnce?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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