作者:Jamie Cool
Microsoft Corporation
3/4/02
翻译:李嘉
北京.东方瑞道
2004-6-3
(接上篇)
Method #2: Manifest Check – To solve the atomicity problem with direct file checks a level of indirection is needed. To create a level of indirection a manifest file on the server is used. A valid server manifest file for use with the .NET Application Updater component looks like this:
<VersionConfig>
<AvailableVersion>1.0.0.0</AvailableVersion>
<ApplicationUrl>http://localhost/demos/selfupdate/V1/</ApplicationUrl>
</VersionConfig>
AvailableVersion specifies the assembly version number of the latest available version. The ApplicationURL property specifies the URL where that version of the application resides. When the administrator wants to update the client applications, they would copy the new version of the app up to the Web server and modify the server manifest file appropriately. The client itself will then detect that the server manifest file has changed and download the manifest file. The client then compares the assembly version number specified in the manifest with the assembly version number of the application’s .exe file. If the server manifest file AvailableVersion is newer, the application knows it’s time to perform an update. This approach has none of the atomicity problems of the previous approach and is the recommended way to check for updates for most applications.
方法二.显式检查----为解决直接文件检查存在的原子问题,有必要进行一定级别的间接检查。为产生一间接级别,在服务器上使用一个显式的文件。一个可和.NET应用程序更新组件使用的有效的服务器显式文件大致是这个样子:
<VersionConfig>
<AvailableVersion>1.0.0.0</AvailableVersion> <ApplicationUrl>http://localhost/demos/selfupdate/V1/</ApplicationUrl>
</VersionConfig>
AvailableVersion指定最新的可用程序集的版本号。ApplicationURL属性指定该版本应用程序所在的URL地址。当管理员想要更新客户端应用程序时,他们就会将应用程序的新版本拷贝到Web服务器上并且适当的修改服务器显式文件。客户端自身会探测到服务器显式文件已被修改,然后下载显式文件。客户端随后比较显式文件中指定的程序集版本号与应用程序EXE文件的版本号。如果服务器显式文件中的可用版本号较新,应用程序就知道是时间实现更新了。这种方法没有前一种方法的原子问题,对大多数应用程序而言是推荐使用的方法。
Method #3: XML Web Service Check – XML Web services provide a way to perform more advanced update checks. For example, suppose you wanted to roll out an update to a set of early adopters before you rolled it out to the rest of your users. If the client application calls an XML Web service to check if an update is available, that XML Web service could then look up that user in a database and determine if the user is an early adopter or not. If they are, the XML Web service could return a value indicating that an update is available. If not, the Web service could return a value indicating that a new update is not available. Because the Web service used to check for updates could take many forms depending on what custom functionality is desired, the .NET Application Updater component does not provide direct XML Web service support. To use an XML Web service to check for updates, first build the XML Web service and then hook the OnCheckForUpdate event. This allows the poller thread’s update check to be replaced with your own custom check. The OnCheckForUpdate event has a return value to indicate whether an update was detected or not.
方法三:XML Web Service 检查----XML Web Services提供一种更高级的更新检查的方式。比如,假定你希望在转出更新你的其他用户之前先对一系列早期用户进行更新,如果客户端应用程序调用一个XML Web Service来检查一项更新是否可用,那个XML Web Service还可以在数据库中查询该用户并判断该用户是否是早期用户。如果他们是早期用户,XML Web Service就返回一个值表示更新可用。如果不是,Web Service就返回一个值表示更新不可用。因为采用Web Service为更新做检查能够根据客户端所希望的功能采取许多形式,.NET 应用程序更新组件并不提供直接XML Web Service支持。采用XML Web Service来进行更新检查,首先建立XML Web Service并挂钩OnCheckForUpdate事件。这样就允许你自己的自定义检查代替轮询者线程更新检查。OnCheckForUpdate事件有一个返回值,该值表示更新是否被检测到。
(未完待续)