Skip to content

TargetFramework .NET Standard 2.0+ crashes on launch, can't find assembly System.Text.Json #42271

Open
@raulsntos

Description

@raulsntos

Godot version:

  • 3.2.3 mono stable
  • 4.0 mono compiled at commit d425cf6

OS/device including version: Ubuntu 20.04

Issue description:

Godot 3.2.3 was released and includes PR #41408 which, as I understand, should allow me to change the framework to .NET Standard 2.0 or greater. So I tried changing the framework to netstandard2.1 and found this issue.

The game compiles fine but when launching it, it immediately crashes with the error:

E 0:00:00.509   debug_send_unhandled_exception_error: System.IO.FileNotFoundException: Could not load file or assembly 'System.Text.Json, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies.
  <C++ Error>   Unhandled exception
  <C++ Source>  modules/mono/mono_gd/gd_mono_utils.cpp:424 @ debug_send_unhandled_exception_error()

The .csproj is as follows:

<Project Sdk="Godot.NET.Sdk/3.2.3">
  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="System.Text.Json" Version="4.7.2" />
  </ItemGroup>
</Project>

This only happens when changing the framework to netstandard2.0 or netstandard2.1, I have found that both of those throw that error, but if the framework is kept as net472 it works fine. I'm not sure if 3.2.3 is supposed to work well with .NET Standard since the default is still net472 so I tried compiling master as well and got the same results.

Steps to reproduce:

  1. Create a new project
  2. Change TargetFramework to netstandard2.1
  3. Add System.Text.Json package (dotnet add package System.Text.Json)
  4. Launch Game in Editor
  5. Game builds and launches but immediately crashes

Minimal reproduction project:
NetStd21.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions