System.Memory.dll present in Unity 2021.2.0f1
Closed this issue · 5 comments
In Unity 2021.2.0f1, System.Memory.dll is now included, leading to a conflict with the one provided in this package.
A quick fix is to
- eject the package (move it from the
Library/PackageCache/com.solidalloy.type-references@2.11.4
toPackages/com.solidalloy.type-references@2.11.4
) - locate
Editor/DLLs/TypeReference_System.Memory.dll
andEditor/DLLs/TypeReference_System.Buffers.dll
files - Add
NET_STANDARD_2_0
to theDefine Constraints
list, and click the apply button.
The NET_STANDARD_2_0 label will prevent the DLL to be loaded in a .Net Standard 2.1 profile, which shipped with Unity 2021.2.
Now locate Editor/TypeReferences.Editor.asmdef
, you will find the System.Memory.dll references is inactive.
You can also use !UNITY_2021_2_OR_NEWER
instead of NET_STANDARD_2_0
, which could be a bit more accurate.
I also suggest to depends on UnityNuGet, read more at https://medium.com/openupm/registry-changes-to-conform-to-net-standard-2-1-shipped-with-unity-2021-2-1e9753d49826
package.json
"dependencies": {
"org.nuget.system.memory": "4.5.4",
"org.nuget.system.runtime.compilerservices.unsafe": "5.0.0"
},
manifest.json
"scopedRegistries": [
{
"name": "package.openupm.com",
"url": "https://package.openupm.com",
"scopes": [
"com.solidalloy.util",
"com.solidalloy.type.references",
"org.nuget.system.memory",
"org.nuget.system.runtime.compilerservices.unsafe",
"com.openupm"
]
}
],
"dependencies": {
"com.solidalloy.type.references": "NEXT_VERSION"
},
or a more compact version
"scopedRegistries": [
{
"name": "package.openupm.com",
"url": "https://package.openupm.com",
"scopes": [
"com.solidalloy",
"org.nuget",
"com.openupm"
]
}
],
"dependencies": {
"com.solidalloy.type.references": "NEXT_VERSION"
},
@favoyang Thanks for the suggestion! I knew about the UnityNuGet uplink feature but didn't use it because I didn't know how well it handled conflicts with DLLs included in Unity's own packages. Now that I encountered a situation where depending on UnityNuGet resolves a problem, I'm glad to start using it.
Tested 2.11.5 with Unity 2021.2.0f1, and 2021.1.27f1. It works.