Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Unity Editor fails to load assembly but everything works fine in player build.

Discussion in 'Scripting' started by echekanskiy, Feb 19, 2021.

  1. echekanskiy

    echekanskiy

    Joined:
    Aug 16, 2020
    Posts:
    16
    Hi everyone. I am trying to work with System.Text.Json in unity. I collected all dependencies and when trying to enter play mode, following exception thrown:
    Code (CSharp):
    1. FileNotFoundException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
    2. System.Text.Json.JsonEncodedText.Encode (System.String value, System.Text.Encodings.Web.JavaScriptEncoder encoder) (at <156be8dd8a8748a88733a94decab76f8>:0)
    3. System.Text.Json.JsonSerializer..cctor () (at <156be8dd8a8748a88733a94decab76f8>:0)
    4. Rethrow as TypeInitializationException: The type initializer for 'System.Text.Json.JsonSerializer' threw an exception.
    5. TestBehaviour.Start () (at Assets/Scripts/TestJson/TestBehaviour.cs:10)
    But when I build standalone player, everything works fine and code executed as expected.

    Any additional information I can provide to solve this issue?
    Thanks in advance.
     
  2. echekanskiy

    echekanskiy

    Joined:
    Aug 16, 2020
    Posts:
    16
    Must to notice that all dlls located in separate folders. Moving them to same folder makes everything working fine, but that is not very desired.