使用Updater Application Block 2.0-.NET心得介绍
1,在Updater Application Blocek2.0中有7个项目文件需要添加:
Microsoft.ApplicationBlocks.Updater.dll Microsoft.ApplicationBlocks.Updater.Downloaders.dll 以上两个需在项目中引用 Microsoft.ApplicationBlocks.Updater.ActivationProcessors.dll Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.dll Microsoft.Practices.EnterpriseLibrary.Common.dll Microsoft.Practices.EnterpriseLibrary.Logging.dll Microsoft.Practices.ObjectBuilder.dll 以上七个文件都需复制到项目输出目录内2,App.config文件应添加到项目中,系统会自动在项目输出目录内生成和其内容一样的,"应用程序名.exe.config",文件
附本人的App.config
<configuration> <configSections> <section name="UpdaterConfiguration" type="Microsoft.ApplicationBlocks.Updater.Configuration.ApplicationUpdaterSettings, Microsoft.ApplicationBlocks.Updater" /> <section name="securityCryptographyConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.Configuration.CryptographySettings, Microsoft.Practices.EnterpriseLibrary.Security.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" /> </configSections> <UpdaterConfiguration defaultDownloader="BITS" applicationId="{F03514FA-970B-430C-9F3B-54579267B364}" manifestUri="http://219.155.XX.XX/update/manifests.xml"> <downloaders> <add name="BITS" type="Microsoft.ApplicationBlocks.Updater.Downloaders.BitsDownloader, Microsoft.ApplicationBlocks.Updater.Downloaders" authenticationScheme="BG_AUTH_SCHEME_NTLM" targetServerType="BG_AUTH_TARGET_SERVER" /> </downloaders> </UpdaterConfiguration> <securityCryptographyConfiguration> <hashProviders> <add algorithmType="System.Security.Cryptography.MD5CryptoServiceProvider, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" saltEnabled="true" type="Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.HashAlgorithmProvider, Microsoft.Practices.EnterpriseLibrary.Security.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" name="MD5CryptoServiceProvider" /> </hashProviders> </securityCryptographyConfiguration> </configuration>applicationId为唯一标识,如和manifests.xml的不一样,则程序不会进行更新
manifestUri为远程manifests.xml文件的地址3,程序是否更新取决于manifests.xml文件的manifestID是否更改,如更改则更新
附本人的manifests.xml文件
<manifest manifestId="{C6F5852B-B331-42D3-9AAC-87A45F961BE1}" mandatory="False" xmlns="urn:schemas-microsoft-com:PAG:updater-application-block:v2:manifest"> <description>a description for this manifest</description> <application applicationId="{F03514FA-970B-430C-9F3B-54579267B364}"> <entryPoint file="Express.exe" parameters="" /> <location>.</location> </application> <files base="http://219.155.XX.XX/update"> <file source="Express.exe" /> </files> <activation> <tasks> <task name="WaitForApplicationExitProcessor" type="Microsoft.ApplicationBlocks.Updater.ActivationProcessors.WaitForApplicationExitProcessor, Microsoft.ApplicationBlocks.Updater.ActivationProcessors"/> <task name="ApplicationDeployProcessor" type="Microsoft.ApplicationBlocks.Updater.ActivationProcessors.ApplicationDeployProcessor, Microsoft.ApplicationBlocks.Updater.ActivationProcessors"/> </tasks> </activation> </manifest>updater Application Blocek本身下载速度较慢,有网友已写出HTTP下载程式,速度比较快.