首页 > 其他分享 >winform 自动更新

winform 自动更新

时间:2023-11-07 15:11:48浏览次数:32  
标签:updateIp xml updatePort location 自动更新 asm winform

原文地址:https://github.com/ravibpatel/AutoUpdater.NET

一:代码中设置

引入 using AutoUpdaterDotNET;

string updateIp =**.**.**.**;  //ip地址

string updatePort = ****;//端口号

using (TcpClient client = new TcpClient())
{
IAsyncResult tcpResult = client.BeginConnect(updateIp, updatePort, null, null);
if (!tcpResult.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(3)))
{
DialogResult dr = MessageBox.Show(String.Format("自动更新端口无法访问{0}:{1},请联系运维人员!是否继续使用当前版本?", updateIp, updatePort), "前台显示!", MessageBoxButtons.OKCancel);

if (dr == DialogResult.Cancel)
{
Environment.Exit(0);
}
//MessageBox.Show(String.Format("自动更新端口无法访问{0}:{1},请联系运维人员!!,将继续使用当前程序", updateIp, updatePort))

}
}

//----------自动更新----------
Assembly asm = Assembly.GetExecutingAssembly();

AssemblyCopyrightAttribute asmcpr = (AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(asm, typeof(AssemblyCopyrightAttribute));
AssemblyCompanyAttribute asmcpn = (AssemblyCompanyAttribute)Attribute.GetCustomAttribute(asm, typeof(AssemblyCompanyAttribute));

string version = string.Format("{0} {1}", asmcpr.Copyright, asmcpn.Company);
AutoUpdater.UpdateMode = Mode.ForcedDownload;

 AutoUpdater.Start(String.Format("http://{0}:{1}/spdupdate.xml", updateIp, updatePort), asm);//开发库更新

ServicesDto.Version = asm.GetName().Version.ToString();

在程序中设置版本号:

 二、服务中设置

1、在nginx.conf 中配置自动更新地址:

server {
        listen 更新端口号 ;
        server_name _;


        location / {
            root /home/放自动更新文件的文件夹地址名称;
        }

        location /SPD3 {
            root /home/spdtest/SPD3_PDA/;
        }


        error_page 404 /404.html;
        location = /404.html {
        }

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        }
    }

2、写一个xml文件

<?xml version="1.0" encoding="UTF-8" standalone="no"?><item>
    <version>1.2.8.5</version>
    <url>http://ip:端口/Debug.zip</url>
    <mandatory mode="2">true</mandatory>
</item>

3、更新的包(必须为.zip)和xml都放在nginx配置好的文件夹目录下面

 4、访问:http://ip:端口/spdupdate.xml  可成功访问则配置成功

标签:updateIp,xml,updatePort,location,自动更新,asm,winform
From: https://www.cnblogs.com/my2020/p/17815046.html

相关文章

  • 界面组件Telerik UI for WinForms中文教程 - 如何自定义应用程序文件窗口?
    TelerikUIforWinForms包含了一个高度可定制的组件,它取代了.NET中默认的OpenFileDialog。在下一个更新版本中,会发布一个向对话框浏览器提那家自定义位置的请求功能,本文演示了这个和另一个自定义功能,它可以帮助用户在浏览文件夹时快速选择最后修改的文件,自定义将根据最近的日期/......
  • 在Winform中通过LibVLCSharp回调函数获取视频帧
    参考资料:VlcVideoSourceProvider优点:实现视频流的动态处理。缺点:视频解码(CPU/GPU)后图像处理CPU占用率高。在Winform中通过LibVLCSharp组件获取视频流中的每一帧图像,需要设置回调函数,主要是SetVideoFormatCallbacks和SetVideoCallbacks,其定义如下所示:///<summary>///Setde......
  • Winform中使用Log4Net实现日志记录到文件并循环覆盖
    场景log4nethttps://logging.apache.org/log4net/TheApachelog4netlibraryisatooltohelptheprogrammeroutputlogstatementstoavarietyofoutputtargets.log4netisaportoftheexcellentApachelog4j™frameworktotheMicrosoft®.NETruntime.We......
  • winform切换页面
    布局效果如下图: 首先在主窗体后台代码声明需要打开的窗体变量,代码如下:1publicpartialclassForm1:Form2{3ButtonbtnShadow;//作为中间寄存button,用于显示4Homehome;5Settingsetting;6Recordrecord;7......
  • Winform高亮显示图标和标题
    效果下如图: 创建ActivateButton公用方法,代码如下:privatevoidActivateButton(objectsenderBtn,Colorcolor1,Colorcolor2,Colorcolor3){if(senderBtn!=null){DisableButton();//B......
  • C# winform捕获程序异常内容
    staticvoidMain(){Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Application.ThreadException+=Application_ThreadException;Application.Run(newForm1());}privatestaticvoidApplication_Threa......
  • c# winform获取gridview数据
    //取单元格数据三种方法this.dataGridView1[e.ColumnIndex,e.RowIndex].Value.ToString();//第一种取法this.dataGridView1.Rows[e.RowIndex].Cells["你所要取值的列名称"].Value.ToString();//第二种取法this.dataGridView1.Cur......
  • C# winform控件大小跟随窗体大小改变
    intiFormWidth,iFormHeight;//初始窗体宽高//窗体加载事件privatevoidForm1_Load(objectsender,EventArgse){iFormWidth=this.Width;//初始宽iFormHeight=this.Height;//初始高WriteIn_Tags(this);//记录初始控件信息}//调整控件大小事件privat......
  • 去除WinForm程序中的Devexpress弹窗
    去除WinForm程序中的Devexpress弹窗///<summary>///应用程序的主入口点。///</summary>[STAThread]staticvoidMain(){if(!CheckInstance()){Application.Exit();......
  • winform圆角窗体实现
    1、窗体的FormBorderStyle设置成None,不要控制边框2、窗体属性中TransparencyKey和BackColor颜色设置成相同的,这样,窗体就透明了3、以此为基础,制作透明不规则窗体,可以在窗体上设圆角背景图片4、将图片调整为像素级的清晰颜色,不然就会有如下图的绿边,以下颜色为00ff00 color.......