Errors when attempting to use external DLL with dependency on System.Text.Json

Hey all, I’m trying to use an external library for a project I’m working on, the issue is that it has a dependency on System.Text.Json, Microsoft’s own JSON parsing library. After installing nuget for Unity and then importing the System.Text.Json package, I am left with these 4 errors:

Error: Could not load signature of System.Text.Json.JsonSerializer:smile:eserializeAsync due to: Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. assembly:System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 type:<unknown type> member:(null) signature:<none>
Error: Could not load signature of System.IAsyncDisposable:smile:isposeAsync due to: Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. assembly:System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 type:<unknown type> member:(null) signature:<none>

Unloading broken assembly Assets/Packages/System.Text.Json.4.7.2/lib/netstandard2.0/System.Text.Json.dll, this assembly can cause crashes in the runtime

Unloading broken assembly Assets/Packages/Microsoft.Bcl.AsyncInterfaces.1.1.0/lib/netstandard2.0/Microsoft.Bcl.AsyncInterfaces.dll, this assembly can cause crashes in the runtime

(Had to make the first two errors in code blocks or else some text showed up as emojis)

I have made sure that System.Threading.Tasks.Extensions is installed (nuget automatically installed it as a dependency), but the installed version is 4.5.4. After much googling, I have heard whispers of “binding redirects” in an app.config file, but I can’t seem to locate this file in my project, the whole concept also seems like a bit of a workaround or hack more than an actual solution to the issue. It would also appear that not many people use System.Text.Json in Unity, as Unity provides its own JSON handling, so there’s not much specific help on that front.

My question: How would I go about getting this external library working in Unity?

Thank you for your time,
nightscout01

1 Like

I can’t even get System.Text.Json to appear either.

Did you find a solution to this?

I am having a similar problem trying to load ASW SDK dlls. Can anyone explain what this error is about?

In my case I had to use nuget to add the Microsoft.Bcl.AsyncInterfaces package to the solution, then copy the DLL that arrived to the plugins folder. That allowed things to work.

1 Like