NewtonSoft Serialization Exception

Hi i have a shared library i use on both client and server, most of JSON works fine, but in this example i have List.
Newtonsoft.Json.JsonSerializationException: Type specified in JSON 'System.Collections.Generic.List1[[RetrobineShared.DTOs.ItemDto, RetrobineShared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' is not compatible with 'System.Collections.Generic.List1[[RetrobineShared.DTOs.ItemDto, RetrobineShared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. Path 'UserBoard.Items.$type', line 1, position 267.
Newtonsoft.Json.JsonSerializationException: Type specified in JSON 'System.Collections.Generic.List1[[RetrobineShared.DTOs.ItemDto, RetrobineShared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' is not compatible with 'System.Collections.Generic.List1[[RetrobineShared.DTOs.ItemDto, RetrobineShared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'. Path 'UserBoard.Items.$type', line 1, position 267.
7 Replies
ACiDCA7
ACiDCA72mo ago
well have you ever changed the versionumber of the shared lib? could be that you are usign two different versions also different version of newtonsoft could be the issue
MCUnderground
MCUnderground2mo ago
Well, i have not changed the version number, i made sure they both reference same dll. Will check about newtonsoft version since i am not sure if they are the same.
ACiDCA7
ACiDCA72mo ago
just to be sure since you didnt provide too much information... you issue is that de/-serialization is working on server/client but not on the other right? or is this a general problem?
MCUnderground
MCUnderground2mo ago
Well version are same. De/Serialization works fine, until List is not involved, when list is involved, it has System.Private.CoreLib in $type(im using TypeNameHandling). Also since this is also Godot 4.3 C# building to android could be their problem, with dependencies. Just wanted to ask here, if this has any solutions and is a common error. I will write at Godots discord also, since building to Android with C# project is still new.
ACiDCA7
ACiDCA72mo ago
welp i ve no experience with android+c#/godot so im out
MCUnderground
MCUnderground2mo ago
Got it working, by changing TypeNameHandling.All to TypeNameHandling.Objects.
The Fog from Human Resources
dont use newtonsoft :kadse:
Want results from more Discord servers?
Add your server