dotnet / WatsonTcp

WatsonTcp is the easiest way to build TCP-based clients and servers in C#.
MIT License
599 stars 117 forks source link

Issue when AOT enabled #298

Open berik-99 opened 1 month ago

berik-99 commented 1 month ago

I start by giving a big thank you to the creator of the library for all the hard work done so far and to all the contributors!

I tried to use the new AOT publishing feature, but I encountered some problems:

First Problem

The client execution stops with a NullReferenceException when calling the Connect() method, which obviously halts the execution. the stack trace is:

System.NullReferenceException: 'Object reference not set to an instance of an object.'
   at WatsonTcp.WatsonTcpClient.Connect()
   at Program.<Main>$(String[] args)

Steps to reproduce:

  1. Create a Console Application project with AOT disabled and copy the server example from the README.
  2. Create a second Console Application project with AOT enabled, and copy the client example from the README.
  3. Start the server first, then the client.

Second Problem

The server seems to work initially, but when a client connects, it is immediately disconnected without any direct exceptions on either side, although two exceptions are logged in the server application's debug console:

Exception thrown: 'System.InvalidOperationException' in System.Text.Json.dll
Exception thrown: 'System.InvalidOperationException' in System.Private.CoreLib.dll

Steps to reproduce:

  1. Create a Console Application project with AOT enabled and copy the server example from the README.
  2. Create a second Console Application project with AOT disabled, and copy the client example from the README.
  3. Start the server first, then the client.