SocketIOUnity icon indicating copy to clipboard operation
SocketIOUnity copied to clipboard

Build error of System.Text.Json in il2cpp while using NewtonsoftJsonSerializer

Open wout-junius opened this issue 2 years ago • 1 comments

So when i try to build to il2cpp i get this building error: Mono.Linker.MarkException: Error processing method: 'System.Void System.Text.Json.Nodes.JsonArray::Add(T)' in assembly: 'System.Text.Json.dll'

So this is how i use the code. As you see i set the JsonSerializer to NewtonsoftJsonSerializer as said in the Readme.

string deviceId = SystemInfo.deviceUniqueIdentifier;

            this.socket = new SocketIOUnity(uri, new SocketIOOptions
            {
                Query = new Dictionary<string, string>
                {
                    {"token", "UNITY" }
                }
                ,
                Transport = SocketIOClient.Transport.TransportProtocol.WebSocket
            });

            var jsonSerializer = new NewtonsoftJsonSerializer();

            socket.JsonSerializer = jsonSerializer;
            socket.OnConnected += async (sender, e) =>
            {
                await socket.EmitAsync("register", deviceId);
            };

            this.socket.OnUnityThread("readyDevice", onReady);

            socket.ConnectAsync();

Is it possible to get a version that is whitout System.text.json so it does not need to build that package.

wout-junius avatar Aug 18 '22 08:08 wout-junius

maybe fixed https://github.com/itisnajim/SocketIOUnity/pull/37 try a newer version of SocketIOUnity and maybe update unity too, see: https://github.com/itisnajim/SocketIOUnity/issues/36

itisnajim avatar Nov 29 '22 11:11 itisnajim