-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
area-System.Net.Socketsbugtenet-compatibilityIncompatibility with previous versions or .NET FrameworkIncompatibility with previous versions or .NET Framework
Milestone
Description
I was working on a UDP library when I hit this miserable exception. Attached is the minimal project I can think of to reproduce the exception.
Compile and run this project with no debugger attached, and you should see the exception details,
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Net.Sockets.SocketAsyncEventArgs.InnerStartOperationReceiveMessageFrom()
at System.Net.Sockets.Socket.ReceiveMessageFromAsync(SocketAsyncEventArgs e)
at SocketAsyncClose.Program.<>c__DisplayClass1_0.<Main>b__0() in c:\users\lextm\documents\visual studio 2017\Projects\SocketAsyncClose\SocketAsyncClose\Program.cs:line 36
This piece of code tries to reuse SocketAsyncEventArgs objects. And it works fine if Socket.ReceiveAsync or Socket.ReceiveFromAsync is used.
I tested it on Windows 10 (latest patches, .NET Core 1.0 and 1.1), and both cases give the same exception. I tested on macOS (latest stable. .NET Core 1.0 and 1.1), and cannot reproduce the exception.
Not surprised, as it should be something wrong in SocketAsyncEventArgs.Windows.cs I think and is Windows only.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-System.Net.Socketsbugtenet-compatibilityIncompatibility with previous versions or .NET FrameworkIncompatibility with previous versions or .NET Framework