我有一个更新程序应用程序,当更新可用时正在启动。此应用程序只是将新的 exe 下载到指定路径,但突然它不再工作了。更新程序下载大小为 0kb 的文件并且没有给出任何错误。
两个月前,我将新的 exe 上传到服务器,许多客户成功下载了该文件。昨天,我的一位客户注意到他开始使用该应用程序并且更新失败。更新程序在许多客户端上运行并且始终有效。会不会是服务器问题?
这是 C# 中的更新程序代码:
public void StartUpdate()
{
WebClient webclient = new WebClient();
try
{
//webclient.DownloadFile("http://www.example.nl/folder/example.exe", @"C:\example\example.exe");
webclient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(webclient_DownloadProgressChanged);
webclient.DownloadFileCompleted += new AsyncCompletedEventHandler(webclient_DownloadFileCompleted);
webclient.DownloadFileAsync(new Uri("http://www.example.nl/folder/example.exe"), @"C:\example\example.exe");
}
catch (Exception)
{
MessageBox.Show("Download Failed.\n\nPlease contact your system administrator");
Application.Exit();
}
}
void webclient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
label1.Text = "Download successfully!";
label3.Text = "Download complete!";
timer2.Enabled = true; //here some other magic happens like start the program and exit this updater.
}
void webclient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
progressBar1.Maximum = (int)e.TotalBytesToReceive / 100;
progressBar1.Value = (int)e.BytesReceived / 100;
}
我在存储 exe 文件的 CentOS 上运行 Apache。文件夹/文件权限没问题。当我在任何浏览器中打开 exe URL 时,文件已成功下载。在过去的 2 个月内,我从未更改过 exe 文件,也从未更改过网络服务器上的任何其他设置。这种方法工作了 2 年,现在它自动停止工作。
更新:
System.Net.WebException: The request has been aborted: Cannot create a secure SSL / TLS channel.
at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult)
at System.Net.WebClient.GetWebResponse (WebRequest request, IAsyncResult result)
at System.Net.WebClient.DownloadBitsResponseCallback (IAsyncResult result) A first chance exception or type 'System.ComponentModel.Win32Exception' occurred in System.dll