一. 基本思路
     一直做Web Form开发,最近开始尝试了一下Win Form,做了一个小系统,在发布了第一个可用版本之后,顺便实现了自动更新功能。之前没有这方面的经验,也没有翻阅相关资料,自己想了一个简单的思路,如有笑话之处,恳请批评指正。
    基本上就是这样的:
    客户端有两个子程序,简单的讲就是两个EXE,一个主的应用程序,一个自动Live Update程序,而在服务端,是一个WCF,提供程序版本更新信息和更新文件。
     每当程序启动(或手动点“检测更新”),主程序会调用服务端的WCF检测更新,若检测到新版本,则启动Live Update程序,同时关闭自身。
     Live Update启动后,调用服务端WCF,获取文件列表,然后直接下载更新文件并覆盖本地文件。完毕后启动主程序,同时关闭自身,这样,一次自动更新就完了。
二. 系统架构
    C#WinForm App自动更新(Live Update)架构
三. 序列图
    C#WinForm App自动更新(Live Update)架构

四. 其它
1. 检测新版本
     在WCF中会有一个XML配置文件,用于客户检测版本和更新文件。
    
2. 下载文件以及覆盖旧文件
     Live Update下载文件后先保存在临时文件夹,下载完毕后再从临时文件夹覆盖主应用程序的旧文件。防止自动更新中途失败导致主应用程序不可用。

3. WCF Contract(仅供参考)

C#WinForm App自动更新(Live Update)架构using System;
C#WinForm App自动更新(Live Update)架构
using System.Collections.Generic;
C#WinForm App自动更新(Live Update)架构
using System.Linq;
C#WinForm App自动更新(Live Update)架构
using System.Text;
C#WinForm App自动更新(Live Update)架构
using System.ServiceModel;
C#WinForm App自动更新(Live Update)架构
C#WinForm App自动更新(Live Update)架构C#WinForm App自动更新(Live Update)架构
namespace WendyFinance.UpdateCenter.Contract C#WinForm App自动更新(Live Update)架构{
C#WinForm App自动更新(Live Update)架构
C#WinForm App自动更新(Live Update)架构     [ServiceContract]
C#WinForm App自动更新(Live Update)架构C#WinForm App自动更新(Live Update)架构    
public interface IAutoUpdate C#WinForm App自动更新(Live Update)架构{
C#WinForm App自动更新(Live Update)架构
C#WinForm App自动更新(Live Update)架构         [OperationContract]
C#WinForm App自动更新(Live Update)架构        
bool CheckUpdate(string clientVersion);
C#WinForm App自动更新(Live Update)架构
C#WinForm App自动更新(Live Update)架构         [OperationContract]
C#WinForm App自动更新(Live Update)架构        
string GetCurrentVersion();
C#WinForm App自动更新(Live Update)架构
C#WinForm App自动更新(Live Update)架构         [OperationContract]
C#WinForm App自动更新(Live Update)架构        
string GetUpdateDescription();
C#WinForm App自动更新(Live Update)架构
C#WinForm App自动更新(Live Update)架构         [OperationContract]
C#WinForm App自动更新(Live Update)架构         List
<string> GetFileList();
C#WinForm App自动更新(Live Update)架构
C#WinForm App自动更新(Live Update)架构         [OperationContract]
C#WinForm App自动更新(Live Update)架构        
string GetFile(string fileName);
C#WinForm App自动更新(Live Update)架构     }

C#WinForm App自动更新(Live Update)架构}
文件来自:http://www.cnblogs.com/guozhijian/archive/2008/01/25/1052802.html

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-21
  • 2022-01-18
  • 2022-12-23
  • 2022-12-23
  • 2021-10-26
  • 2021-09-22
猜你喜欢
  • 2021-10-02
  • 2021-12-20
  • 2022-12-23
  • 2021-10-25
  • 2022-12-23
  • 2021-11-01
  • 2021-09-22
相关资源
相似解决方案