此代码永远悬而未决,不是检索请求/响应流,而是在WebRequest的创建中:
public static void PublishFileList(List<string> files, string url) {
string content = files.Aggregate<string>((res, file) => res+file+"\n");
byte[] contentBytes = Encoding.UTF8.GetBytes(content);
WebRequest request = WebRequest.Create(url);
Console.WriteLine(content);
request.GetRequestStream().Write(contentBytes, 0, contentBytes.Length);
request.GetRequestStream().Close();
request.GetResponse().Close();
}
永远不会执行WriteLine
调用。这是使用有效的URL调用的:
PublishFileList(files, "http://example.com/update");
我不知道原因。我之前使用过WebRequests,这种情况从未发生在我身上(也不是其他任何人,显然,因为谷歌搜索没有给出任何结果)
编辑:
这是调用堆栈:
[Managed to Native Transition] in
System.Net.WinHttpWebProxyBuilder.BuildInternal () in
System.Net.WebProxyDataBuilder.Build () in
System.Net.AutoWebProxyScriptEngine.GetWebProxyData () in
System.Net.WebProxy.UnsafeUpdateFromRegistry () in
System.Net.WebProxy..ctor (enableAutoproxy=true) in
System.Net.Configuration.DefaultProxySectionInternal..ctor (section={System.Net.Configuration.DefaultProxySection}) in
System.Net.Configuration.DefaultProxySectionInternal.GetSection () in
System.Net.WebRequest.get_InternalDefaultWebProxy () in
System.Net.HttpWebRequest..ctor (uri={System.Uri}, servicePoint=(null)) in
System.Net.HttpRequestCreator.Create (Uri={System.Uri}) in
System.Net.WebRequest.Create (requestUri={System.Uri}, useUriBase=false) in
System.Net.WebRequest.Create (requestUriString="http://example.com/update") in
Updater.MainClass.PublishFileList (files=Cannot evaluate expression because the thread is stopped in native code., url="http://example.com/update") in <redacted>