.net 程序在线升级

DLL 下载地址
https://download.youkuaiyun.com/download/letunihao/15805303

http://www.cnblogs.com/KnightsWarrior/archive/2010/10/20/1856255.html
http://www.cnblogs.com/stoneniqiu/p/3806558.html
配置IIS
https://blog.youkuaiyun.com/u011635349/article/details/79972326
https://blog.youkuaiyun.com/zy010101/article/details/86580506
Apache 用户名和密码验证
http://blog.youkuaiyun.com/liushu_it/article/details/18735449
借鉴了圣殿骑士写的dll,更改了下载后删除old文件

配置IIS 的时候,身份认证打开匿名认证就可以了;
生成AutoUpdater.dll 的.net框架要和所写项目的.NET框架一致;

  1. 在引用中添加AutoUpdater.dll,代码中添加
Imports KnightsWarriorAutoupdater        '实现自动更新的dll
  1. 服务器端配置文件 AutoupdateService.xml
    下面的代码示例会把文件夹tt以及里面的1.txt文件一起拷贝到客户端中,size为文件大小,并非占用空间,必须写对
<?xml version="1.0" encoding="utf-8"?>
<updateFiles>
	<file  path="1.txt"  url="http://10.*.*.*:8011/SerialWrite/tt/1.txt"  lastver="3.2.1.2" size="8" needRestart="True"  />
</updateFiles>
  1. 客户端配置文件 AutoUpdater.config
<?xml version="1.0" encoding="utf-8"?>
<Config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Enabled>true</Enabled>
  <ServerUrl>http://10.*.*.*:8011/SerialWrite/AutoupdateService.xml</ServerUrl>
  <UpdateFileList>
    <LocalFile path="1.txt" lastver="3.2.1.2" size="8" />
  </UpdateFileList>
</Config>
  1. 更新的代码
'*********************
'自动更新程序
'*********************
Dim bHasError As Boolean = False
Dim autoUpdater As IAutoUpdater = New AutoUpdater()
Try
	autoUpdater.Update()
Catch ex As WebException
	MessageBox.Show("连接自动升级服务器出错,请检查网络连接或联系软件提供者。(Connect remote update server fail.)", "更新程序(UPDATE SOFTWRAE)", MessageBoxButtons.OK, MessageBoxIcon.Error)
	bHasError = True
Catch ex As XmlException
	MessageBox.Show("服务器上的升级文件(AutoupdateService.xml)出错。(Download the upgrade file error.)", "更新程序(UPDATE SOFTWRAE)", MessageBoxButtons.OK, MessageBoxIcon.Error)
	bHasError = True
Catch ex As Exception
	MessageBox.Show("更新程序出错。(An error occurred during the upgrade process.)", "更新程序(UPDATE SOFTWRAE)", MessageBoxButtons.OK, MessageBoxIcon.Error)
	bHasError = True
Finally
	If bHasError = True Then
		Try
			autoUpdater.RollBack()
		Catch ex As Exception
			MsgBox(ex.Message)
		End Try
	End If
End Try
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

huangle63

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值