Lack of recognition of the system.text.json in Rhino 8."

I am developing a Grasshopper plugin in Rhino 7 and 8. In this plugin, I have used a system.text.json file that works perfectly in Rhino 7 without any issues, but I encounter the following error in Rhino 8.I am using version system.text.json 8.0.3. The only solution I found is setting the runtime to .NET Framework in Rhino 8. I am sure about copying the DLL next to the plugin file.

System.IO.FileLoadException
HResult=0x80131621
Message=Could not load file or assembly ‘System.Text.Json, Version=8.0.0.3, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’. Could not find or load a specific file. (0x80131621)
Source=EmreIstikam001

I had the same issue… Did you solve the problem?

I solved this issue by using Newtonsoft.Json instead of System.text.json.
Hope that helps!

1 Like

Add it as a NuGet package.

– Dale

I tried this but the problem still persists.

I tried this solution and it solved this weird problem.

One thing you might be running into here is that you’re using a version of System.Text.Json that is newer than the one that Rhino ships with. We have not yet implemented a way to use AssemblyLoadContexts to load plugins, so there can only be one copy of that dll loaded when running in .NET Core. You might be able to get it working by using System.Text.Json 7.0.0.

Hope this helps!

I was unable to get it to work by using an older version of STJ. I’ve tried with many different versions of STJ, and none of them lead to a solution. Even when I use a NuGet package with STJ version 8.0.0 I still get the error.

I would like to add some context for my followup.

My .csproj contains these lines:

  <ItemGroup>
    <PackageReference Include="Grasshopper" Version="8.9.24194.18121" IncludeAssets="compile;build" />
    <PackageReference Include="System.Resources.Extensions" Version="8.0.0" IncludeAssets="compile;build" />
    <PackageReference Include="System.Drawing.Common" Version="8.0.7" IncludeAssets="compile;build" />
    <PackageReference Include="System.Text.Json" Version="8.0.0" IncludeAssets="compile;build" />
  </ItemGroup>

My project has a NuGet dependency on System.Text.Json 8.0.0:

And yet when I try to use my built .gha in Grasshopper, I get the “Could not load file or assembly…” problem which is the subject of this thread.

I feel like I’m doing something wrong. I’m newer at using VS Code. But the fact that I’ve explicitly included System.Text.Json in my NuGet dependencies and yet I still get this error makes me feel confused.

I’ve been searching far and wide for solutions. But my novice-level experience with this particular set of tools is full of barriers. I would love some help with this.

I do not want to switch JSON libraries, because it means I have to re-write that portion of my code. My student wrote the JSON parts that are causing me grief now.

Thanks for your help.

Curtis mentioned that we use System.Text.Json 7.0.0

It seems weird that it’s complaining about 8.0.0.0, but installing 7.0.0 worked. But hey, it worked.