<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Deserialization of a Json response causes FATAL ERROR in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/deserialization-of-a-json-response-causes-fatal-error/m-p/12887637#M3368</link>
    <description>&lt;P&gt;Weird, I'm pretty sure I had used the Newtonsoft deserializer and it made my AutoCAD crash, but now it seems to work just fine.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;return Newtonsoft.Json.JsonConvert.DeserializeObject&amp;lt;List&amp;lt;SubAssemblyTypeDto&amp;gt;&amp;gt;(responseString);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 09 Jul 2024 20:56:44 GMT</pubDate>
    <dc:creator>bsaidiDG51</dc:creator>
    <dc:date>2024-07-09T20:56:44Z</dc:date>
    <item>
      <title>Deserialization of a Json response causes FATAL ERROR</title>
      <link>https://forums.autodesk.com/t5/net-forum/deserialization-of-a-json-response-causes-fatal-error/m-p/12887068#M3366</link>
      <description>&lt;P&gt;I'm currently coding a C# .NET macro for AutoCAD that needs to make a [GET] Api call. Retrieving the content string of the API call works fine, but when I try to deserialize the response string using Flurl or Newton, the AutoCAD crashes with a FATAL ERROR.&lt;/P&gt;&lt;P&gt;And when I try to deserialize the response using:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using JsonSerializer = System.Text.Json.JsonSerializer;&lt;/LI-CODE&gt;&lt;P&gt;for this code:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using HttpClient httpClient = new HttpClient();
HttpResponseMessage result1 = await httpClient.GetAsync(apiUrl);
string result2 = await result1.Content.ReadAsStringAsync();
return JsonSerializer.Deserialize&amp;lt;List&amp;lt;SubAssemblyTypeDto&amp;gt;&amp;gt;(result2, _jsonSerializerOptions);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;U&gt;I get this error&lt;/U&gt;:&amp;nbsp;Could not load file or assembly 'System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. Le fichier spécifié est introuvable.&lt;BR /&gt;at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)&lt;/P&gt;&lt;P&gt;&lt;U&gt;Then when I install the demanded version of System.Memory, I get this error&lt;/U&gt;:&amp;nbsp;Could not load file or assembly 'System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. Le fichier spécifié est introuvable.&lt;BR /&gt;at System.Text.Json.JsonSerializer.Deserialize(String json, Type returnType, JsonSerializerOptions options)&lt;BR /&gt;at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Why is it so complex to deserialize Json strings within the AutoCAD .NET environment? Is there any simpler way?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Thank you!&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2024 16:09:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/deserialization-of-a-json-response-causes-fatal-error/m-p/12887068#M3366</guid>
      <dc:creator>bsaidiDG51</dc:creator>
      <dc:date>2024-07-09T16:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: Deserialization of a Json response causes FATAL ERROR</title>
      <link>https://forums.autodesk.com/t5/net-forum/deserialization-of-a-json-response-causes-fatal-error/m-p/12887438#M3367</link>
      <description>&lt;P&gt;Which version of AutoCAD are you working against? do you add reference to System.Text.Json from Nuget package? Have you looked at your project's output folder (".....\bin\Debug\") to make sure the System.Text.Json.dll and ALL of the dependency assemblies (quite a few of them!) are there? If you do AutoCAD 2025 with .NET 8, you need to edit the *.csproj file to make sure all the DLLs in the Nuget package get outputted when the code is compiled.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I use NewtonSoft for handling https request/response, from AutoCAD 2015 to 2024, without issue. Using System.Text.Json from Nuget package adds ridiculously 9 dependency DLLs to the AutoCAD plugin, while with NewtonSoft, only 1 dll (NewtonSoft.Json.dll) goes with the Plugin DLL, or you do not event need to deploy NewtonSoft.Json.dll at all (set Copy Local to false), because AutoCAD comes with NewtonSoft.Json.dll (in the C:\Program Files\Autodesk\AutoCAD20xx\ folder).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2024 19:03:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/deserialization-of-a-json-response-causes-fatal-error/m-p/12887438#M3367</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2024-07-09T19:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: Deserialization of a Json response causes FATAL ERROR</title>
      <link>https://forums.autodesk.com/t5/net-forum/deserialization-of-a-json-response-causes-fatal-error/m-p/12887637#M3368</link>
      <description>&lt;P&gt;Weird, I'm pretty sure I had used the Newtonsoft deserializer and it made my AutoCAD crash, but now it seems to work just fine.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;return Newtonsoft.Json.JsonConvert.DeserializeObject&amp;lt;List&amp;lt;SubAssemblyTypeDto&amp;gt;&amp;gt;(responseString);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2024 20:56:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/deserialization-of-a-json-response-causes-fatal-error/m-p/12887637#M3368</guid>
      <dc:creator>bsaidiDG51</dc:creator>
      <dc:date>2024-07-09T20:56:44Z</dc:date>
    </item>
  </channel>
</rss>

