Calling any mthod of HttpClient (i.e. PostAsync, GetAsync, etc) from within a .NET Core 3.1 WinExe Windows Forms results in error on Windows 10 version 1903.
Issue Title
Calling any method of HttpClient (i.e. PostAsync, GetAsync, etc) or WebClient from within a .NET Core 3.1 WinExe Windows Forms results in error on Windows 10 version 1903.
Reproduction
Your project should have these configurations:
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<Platforms>x64</Platforms>
<LangVersion>8</LangVersion>
<Configurations>Debug;Release</Configurations>
</PropertyGroup>
and attempt any call from HttpClient (i.e. GetAsync, PostAsync, etc)
Results in Error:
UnhandledException: System.InvalidOperationException: 'overlapped' has already been freed.
at System.Threading.ThreadPoolBoundHandleOverlapped.CompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pNativeOverlapped)
Also, be aware that this happens ONLY if you run the EXE file (i,e. MyProject.exe), because if you call directly the underlying dll (i.e. dotnet MyProject.dll) this will work.
Updating Windows 10 to version 1909 or version 2004 fixes the issue.
Seems like the response from the server is being stopped unmexepctedly and it is incomplete most likely due to an incorrect handling of async in the .
Tagging subscribers to this area: @dotnet/ncl Notify danmosemsft if you want to be subscribed.
There's not enough here to go on. It's possible your Windows, .NET, or maybe network drivers were corrupted somehow and updating Windows fixed it. If you are still able to reproduce it and can get us a memory dump, please do!
It is up to you guys. We have reproduced the same bug on 3 of our 30 customers. The same fix the same issue. We have been deubgging for 2 days before we manage to figure out the cause.
Will do the memory dump next time we encounter it.
Not enough info, closing for now. Feel free to reopen once there is more info to make it actionable ... thanks!