Messagepack-csharp: System.Memory DLL is not referenced in Unity project

Created on 13 Nov 2020  路  6Comments  路  Source: neuecc/MessagePack-CSharp

Bug description

I'm getting these two errors repeatedly from my generated resolver script:

Assets\Project\Plugins\Models\MessagePackGenerated.cs(8351,13): error CS0012: The type 'ReadOnlySequence<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

Assets\Project\Plugins\Models\MessagePackGenerated.cs(8512,13): error CS0012: The type 'ReadOnlySpan<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

Repro steps

  1. Install MessagePack C# v2.2.60 for Unity (via the Unity package)
  2. Generate the resolver using the dotnet mpc tool
  3. Get this error after the scripts are finished compiling

Expected behavior

Scripts compile successfully

Actual behavior

Hundreds of errors, which are just the two errors repeating over and over again (for each instance of writer.Write in the generated resolver)

  • Version used: Unity 2019.2.21f1, MessagePack 2.2.60
  • Runtime: IL2CPP, .NET 4.x, Android
mpc question unity

All 6 comments

Worth nothing that I also commented out the using System.Buffers; parts of the generated resolver code since they were causing this issue:

Assets\Project\Plugins\Models\MessagePackGenerated.cs(481,18): error CS0234: The type or namespace name 'Buffers' does not exist in the namespace 'System' (are you missing an assembly reference?)

but I'm not sure if I should've done that

Why not solve it by adding the assembly reference that it's asking for?

Both System.Buffers and System.Memory DLL are already included in the Unity package (I guess I wasn't clear on that, I'll edit the original repro steps), which is why I'm wondering why they're not being detected. They're also part of the MessagePack asmdef, I'm not sure if that has something to do with it.

I also so a similar issue before with the System.Buffers DLL and having to remove the "using System.Buffers" statements in the pregenerated code, but that just introduced more errors for me.

Here are pictures from the Unity setup.
image
image
image

Okay it looks like an issue that's specific to my project. I tried it on a fresh install and there are no errors. I'll try to find out the cause of the conflict, and then close this issue once I have the information (in case it helps other people).

Closing this, sorry for the false alarm. The issue was that the generated resolver was being generated in the wrong csproj.

Was this page helpful?
0 / 5 - 0 ratings