Search Issue Tracker
Fixed in 2022.1.X
Fixed in 2021.2.X
Votes
1
Found in
Issue ID
1367105
Regression
Yes
.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=4.0.1.1, 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:
NuGet Packages:
- 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:
- System.Buffers.dll
- System.Memory.dll
- System.Threading.Tasks.Extensions.dll
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.
-
KuraiAndras
Feb 14, 2022 12:40
Do we know when will this be fixed in 2021.2?
-
MrDizzle26
Oct 29, 2021 15:08
We desperately need this for 2021.2, we'd really appreciate it as we are stuck on b1 until it is done. Thanks!
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
Resolution Note (fix version 2022.1):
The Unity 4.8 reference profile and the Unity JIT profiles have been updated to address the problem. The missing facade dlls have been added where needed.