首先我应该澄清我Proxy
的设置。该地址和任何必要的凭据已在 Web 服务的登录过程中成功使用。当通过代理下载时,它偶尔会成功(大约 25% 的时间),但大多数时候它只是部分下载并通过e.Error
set “完成”(见下文)。
public static void DownloadMyFile(string file)
{
Url = "https://myWebService.com/file.ext";
using (var client = new WebClient())
{
client.Proxy = proxy; //proxy is set and used elsewhere prior to logging in
//I use this event to manipulate my file when finished
client.DownloadFileCompleted += client_DownloadCompleted;
client.DownloadFileAsync(new Uri(Url), file);
}
}
我稍后使用的事件:
public static void client_DownloadCompleted(object sender, AsyncCompletedEventArgs e)
{
//e has an error here, no point in doing anything useful with the file
//Do other "stuff"
}
内部异常文本/堆栈跟踪是:
解密操作失败,见内部异常。
在 System.Net.ConnectStream.EndRead(IAsyncResult asyncResult)
在 System.Net.WebClient.DownloadBitsReadCallbackState(DownloadBitsState 状态,IAsyncResult 结果)。
再次澄清一下:在不使用代理的情况下,这 100% 的时间都可以正常工作。
编辑:第二级内部异常消息是The specified data could not be decrypted
. 没有与之关联的堆栈跟踪