.NET客戶端應(yīng)用程序:.NET應(yīng)用程序更新組件(4)
2024-07-10 13:04:07
供稿:網(wǎng)友
作者: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.
方法二.顯式檢查----為解決直接文件檢查存在的原子問題,有必要進(jìn)行一定級別的間接檢查。為產(chǎn)生一間接級別,在服務(wù)器上使用一個顯式的文件。一個可和.net應(yīng)用程序更新組件使用的有效的服務(wù)器顯式文件大致是這個樣子:
<versionconfig>
<availableversion>1.0.0.0</availableversion> <applicationurl>http://localhost/demos/selfupdate/v1/</applicationurl>
</versionconfig>
availableversion指定最新的可用程序集的版本號。applicationurl屬性指定該版本應(yīng)用程序所在的url地址。當(dāng)管理員想要更新客戶端應(yīng)用程序時,他們就會將應(yīng)用程序的新版本拷貝到web服務(wù)器上并且適當(dāng)?shù)男薷姆?wù)器顯式文件。客戶端自身會探測到服務(wù)器顯式文件已被修改,然后下載顯式文件。客戶端隨后比較顯式文件中指定的程序集版本號與應(yīng)用程序exe文件的版本號。如果服務(wù)器顯式文件中的可用版本號較新,應(yīng)用程序就知道是時間實(shí)現(xiàn)更新了。這種方法沒有前一種方法的原子問題,對大多數(shù)應(yīng)用程序而言是推薦使用的方法。
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提供一種更高級的更新檢查的方式。比如,假定你希望在轉(zhuǎn)出更新你的其他用戶之前先對一系列早期用戶進(jìn)行更新,如果客戶端應(yīng)用程序調(diào)用一個xml web service來檢查一項更新是否可用,那個xml web service還可以在數(shù)據(jù)庫中查詢該用戶并判斷該用戶是否是早期用戶。如果他們是早期用戶,xml web service就返回一個值表示更新可用。如果不是,web service就返回一個值表示更新不可用。因為采用web service為更新做檢查能夠根據(jù)客戶端所希望的功能采取許多形式,.net 應(yīng)用程序更新組件并不提供直接xml web service支持。采用xml web service來進(jìn)行更新檢查,首先建立xml web service并掛鉤oncheckforupdate事件。這樣就允許你自己的自定義檢查代替輪詢者線程更新檢查。oncheckforupdate事件有一個返回值,該值表示更新是否被檢測到。
(未完待續(xù))