Visual Studio 2015 System.Net.HttpWebRequest System.IO.IOException调试运行时但不通过编译的EXE

时间:2019-01-03 19:02:39

标签: windows debugging exception visual-studio-2015 symantec

2019年新年在下面的Visual Studio 2015代码中带来了此调试例外。唯一有效的方法是运行编译的EXE或将Visual Studio 2010与相同的Internet第三方API调用一起使用。我们安装了更新的Symantec Endpoint Protection,除了周日以外,我们一直都进行了调整。我的同事卸载了赛门铁克,我们都多次重启,无济于事。

2019-01-03 08:56:47.3326|ERROR|...:
The underlying connection was closed: An unexpected error occurred on a send. --->
System.IO.IOException: Unable to read data from the transport connection: 
An existing connection was forcibly closed by the remote host. ---> 
System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.TlsStream.CallProcessAuthentication(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean reserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.ConnectStream.WriteHeaders(Boolean async)

---内部异常堆栈跟踪的结尾---

at System.Net.HttpWebRequest.GetResponse()

1 个答案:

答案 0 :(得分:0)

问题开始的同一天,是我们的Web API第三方提供商停止支持TLS 1.0的同一天。据我了解TLS,Windows 10和Visual Studio 2015将默认为TLS 1.0。快速解决方案是在第一个API调用之前使用此VB.NET代码:    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12

从长期来看,我们将消除每个Microsoft的WebRequest调用: “重要

我们不建议您将WebRequest或其派生类用于新开发。而是使用System.Net.Http.HttpClient类。“