Relative Content

Tag Archive for c#jsoncompilationnative

Newtonsoft.Json.JsonSerializationException: Unable to find a constructor

string json = File.ReadAllText($”./assets/JSON/{mapName}.json”); Console.WriteLine(json); var gridMapData = JsonConvert.DeserializeObject<GridMapData>(json); Here im deserializing an object and for release mode it works normally. But when compiled natively (PublishAot) like below: <PropertyGroup> <OutputType>Exe</OutputType> <TargetFramework>net8.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> <PublishAot>true</PublishAot> <InvariantGlobalization>true</InvariantGlobalization> <Platforms>AnyCPU;x64;x86</Platforms> <ApplicationManifest>app.manifest</ApplicationManifest> <AllowUnsafeBlocks>True</AllowUnsafeBlocks> <PublishAot>true</PublishAot> –> here </PropertyGroup> This error Newtonsoft.Json.JsonSerializationException: Unable to find a constructor. start happening ( from the […]