grpc: Unity Package: System.Memory.dll version mismatch
What version of gRPC and what language are you using?
grpc_unity_package.2.27.0-dev C#
What operating system (Linux, Windows,…) and version?
Windows 10 2004
What runtime / compiler are you using (e.g. python version or version of gcc)
Unity 2019.3.0f6
What did you do?
I downloaded the last unity package (2.27.0) from https://packages.grpc.io/, extracted it to the Asset/Plugins folder.
What did you expect to see?
The plugin to work.
What did you see instead?
The Google.Protobuf dll failed to load with the following messages:
Error: Could not load signature of Google.Protobuf.ByteString:get_Span due to: Could not load file or assembly 'System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. assembly:System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 type:<unknown type> member:(null) signature:<none>
Unloading broken assembly Assets/Plugins/Google.Protobuf/lib/net45/Google.Protobuf.dll, this assembly can cause crashes in the runtime
It appears that Google.Protobuf.dll has an assembly reference to version 4.0.1.0 (4.5.2)of System.Memory, but Grpc.Core has a reference to version 4.0.1.1 (4.5.3), and that’s the version that is included in the unity package, so the version used by Protobuf is missing.
Anything else we should know about your project / environment?
I tried upgrading the reference in the Google.Protobuf project to 4.0.1.1 in Visual Studio, but it gave the following error:
Severity Code Description Project File Line Suppression State
Error NU1202 Package System.Memory 4.5.3 is not compatible with netstandard1.0 (.NETStandard,Version=v1.0). Package System.Memory 4.5.3 supports:
- netcoreapp2.1 (.NETCoreApp,Version=v2.1)
- netstandard1.1 (.NETStandard,Version=v1.1)
- netstandard2.0 (.NETStandard,Version=v2.0) Google.Protobuf <removed>\code\protobuf\csharp\src\Google.Protobuf\Google.Protobuf.csproj 1
Downgrading the version used by Grpc seemed to work locally, but that seems less than desirable. Unity doesn’t seem to support loading multiple versions of the same dll or bindingRedirects.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 28
- Comments: 24 (1 by maintainers)
My apologies for the delay: https://gist.github.com/discodonut/d88279f956c1f353b96aab465f4eecf5
This has many caveats:
This script was really meant to be a band-aid until this bug could be fixed, not a true fix.
I’ve checked grpc_unity_package.2.26.0-dev+Unity 2019.3.9f1 works. https://packages.grpc.io/archive/2019/12/a02d6b9be81cbadb60eed88b3b44498ba27bcba9-edd81ac6-e3d1-461a-a263-2b06ae913c3f/index.xml
FYI, downgrading to grpc_unity_package.2.26.0-dev is working without errors.
It is, but I was able to write a script that did this:
This will give you two new merged dlls, one for Grpc and one for Protobuf that can then be used in Unity. It does mean that you will essentially have multiple copies of the dependent dlls in your project. I’ll see if I can release the script I wrote, but I don’t see it as a good long-term solution, ILMerge is also Windows-only last I checked.
Same issue with the grpc_unity_package.2.29.0-dev and Unity 2019.3.5f1
Same issue with latest nightly (grpc_unity_package.2.29.0-dev) and unity 2019.3.0f6
when you say downgrading “the version used by Grpc”. What did you do here, as I’m coming across this error as well.