这个应用程序只是将一个新的exe文件下载到指定的路径,但是突然它不再工作了。更新程序下载大小为0kb的文件,并且不会给出任何错误。
2个月前,我将新的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文件,也没有更改过any服务器上的任何其他设置。
更新:
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发布于 2019-03-29 19:33:37
您的服务器SSL证书似乎已损坏。可能已过期。如果您使用的是自签名证书,请确保导入了用于对服务器证书进行自签名的CA证书。另一种可能是您的服务器(或客户端)的系统时钟无效。所以客户端认为你的证书过期了。
发布于 2019-03-29 19:37:31
程序无法处理安全的uri。我添加了以下行
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;在这条线下
webclient.DownloadFileCompleted += new AsyncCompletedEventHandler(webclient_DownloadFileCompleted);解决了我的问题。
https://stackoverflow.com/questions/55416101
复制相似问题