Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

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

Discussion in 'Editor & General Support' started by nightscout01, Aug 3, 2020.

  1. nightscout01

    nightscout01

    Joined:
    Feb 22, 2020
    Posts:
    1
    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:

    Code (CSharp):
    1. Error: Could not load signature of System.Text.Json.JsonSerializer:DeserializeAsync 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>
    Code (CSharp):
    1. Error: Could not load signature of System.IAsyncDisposable:DisposeAsync 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
     
    Max55555 likes this.
  2. Nanomid

    Nanomid

    Joined:
    Nov 8, 2014
    Posts:
    15
    I can't even get System.Text.Json to appear either.
     
  3. markinovus

    markinovus

    Joined:
    Apr 27, 2021
    Posts:
    5
    Did you find a solution to this?
     
  4. vapidfire

    vapidfire

    Joined:
    Sep 4, 2018
    Posts:
    2
    I am having a similar problem trying to load ASW SDK dlls. Can anyone explain what this error is about?
     
  5. vapidfire

    vapidfire

    Joined:
    Sep 4, 2018
    Posts:
    2
    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.
     
    UnityWizard likes this.