Search Issue Tracker
Fixed in 2022.1.X
Fixed in 2021.2.X
.NETStandard 2.1 in the editor is missing System.Memory, System.Buffers at runtime
When referencing .NETStandard 2.0 assemblies coming from NuGet package like System.Text.Json (https://www.nuget.org/packages/System.Text.Json/5.0.2) we are getting the following error in the Editor (before this, we need to disable validation for assemblies, as there is another set of validation errors separated from this issue)
Error: Could not load signature of System.HexConverter:ToBytesBuffer due to: Could not load file or assembly 'System.Memory, Version=18.104.22.168, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies.
Unloading broken assembly Assets/Scenes/System.Text.Json.dll, this assembly can cause crashes in the runtime
The problem is that this System.Text.Json assembly comes only in .NETStandard 2.0 form but has dependencies to:
- Microsoft.Bcl.AsyncInterfaces (>= 5.0.0)
- System.Text.Encodings.Web (>= 5.0.1)
Special NuGet Packages but when running in a .NET runtime supporting .NET Standard 2.1, these assemblies are included with the runtime:
- System.Buffers (>= 4.5.1)
- System.Memory (>= 4.5.4)
- System.Runtime.CompilerServices.Unsafe (>= 5.0.0)
- System.Numerics.Vectors (>= 4.5.0)
- System.Threading.Tasks.Extensions (>= 4.5.4)
So it seems that the editor doesn't have the special assemblies above (System.Buffers/System.Memory) in the runtime.
Checking further the AOT folder `Data\MonoBleedingEdge\lib\mono\unityaot-win32\Facades` and comparing it to the one used at editor time `Data\MonoBleedingEdge\lib\mono\unityjit-win32\Facades`, we can see that we are missing some of these assemblies:
Copying these DLLs to the `unityjit-win32\Facades` folder is fixing the issue.
Reproducible with a recent 2021.2 or 2022.1
Attached a project ModernDotNet.zip that contains these assemblies to reproduce the issue.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
- Prefab's scripts are constantly reloaded when trying to enter multiple digits or characters into public fields on custom scripts consecutively
- Crash on mono_g_hash_table_find_slot when entering Play Mode
- [iOS] Crash when pressing "Done" on the keyboard layout
- Sprite Atlas remains loaded in memory after scene change or unloading assets
- Decompressing a DeflateStream under IL2CPP misses a few bytes