Xamarin-macios: Build Failed: "Error MT2002: Failed to resolve "System.Buffers.OwnedMemory`1" reference"

Created on 6 Jun 2018  路  9Comments  路  Source: xamarin/xamarin-macios

Steps to Reproduce

Select project > Debug > Generic Device (or my iOS device).

Expected Behavior

Build Successfully and deployed to the device.

Actual Behavior

Build failed with the following error:

/Users/richard/dev/src/.../.../MTOUCH: Error MT2002: Failed to resolve "System.Buffers.OwnedMemory`1" reference from "System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" (MT2002) (MobileProject.iOS)

Environment

=== Visual Studio Professional 2017 for Mac ===

Version 7.5.2 (build 40)
Installation UUID: 1972d8a5-d95a-4b2c-a7b7-da92a3c5c7c9
Runtime:
    Mono 5.10.1.57 (2017-12/ea8a24b1bbf) (64-bit)
    GTK+ 2.24.23 (Raleigh theme)
    Xamarin.Mac 4.4.1.178 (master / eeaeb7e6)

    Package version: 510010057

=== NuGet ===

Version: 4.3.1.4445

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
    2.1.0
    2.0.5
SDK: /usr/local/share/dotnet/sdk/2.1.300/Sdks
SDK Versions:
    2.1.300
    2.1.4
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.10.1/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.2
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Xamarin.Android ===

Version: 8.3.3.2 (Visual Studio Professional)
Android SDK: /Users/richard/Library/Developer/Xamarin/android-sdk-macosx
    Supported Android versions:
        8.0 (API level 26)
        8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 27.0.1
SDK Build Tools Version: 27.0.3

Java SDK: /usr
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Apple Developer Tools ===

Xcode 9.4 (14160)
Build 9F1027a

=== Xamarin.Mac ===

Version: 4.4.1.193 (Visual Studio Professional)

=== Xamarin Inspector ===

Version: 1.4.0
Hash: b3f92f9
Branch: master
Build date: Fri, 19 Jan 2018 22:00:34 GMT
Client compatibility: 1

=== Xamarin.iOS ===

Version: 11.12.0.4 (Visual Studio Professional)
Hash: 64fece5f
Branch: d15-7
Build date: 2018-05-29 20:00:44-0400

=== Build Information ===

Release ID: 705020040
Git revision: cfe2fc0566bc4db990242959de40505a13f58352
Build date: 2018-05-30 11:24:18-04
Xamarin addins: 3ac7413ef51a88e06367313c27aec8f7292752a6
Build lane: monodevelop-lion-d15-7

=== Operating System ===

Mac OS X 10.13.5
Darwin 17.6.0 Darwin Kernel Version 17.6.0
    Tue May  8 15:22:16 PDT 2018
    root:xnu-4570.61.1~1/RELEASE_X86_64 x86_64

Build Logs

...
    MTOUCH : error MT2002: Failed to resolve "System.Buffers.OwnedMemory`1" reference from "System.Memory, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"
Done building target "_CompileToNative" in project "MobileProject.iOS.csproj" -- FAILED.

Done building project "....iOS.csproj" -- FAILED.

Build FAILED.

Example Project (If Possible)

I apologise I cannot share the project as it is proprietary.

However, the project can build successfully if it is to be deployed to simulator.
The build fails only if it is trying to build for physical device.

Extra Information

Following https://developer.xamarin.com/guides/ios/troubleshooting/mtouch-errors/#MT2002 , I have tried fresh install the Visual Studio for Mac. Still doesn't work.

bug iOS need-info

All 9 comments

Hello @imRichardNg any chance you could provide us full build logs?

To get full build logs just set the log verbosity to diagnostic at the following locations:

  • On Visual Studio for Mac: Preferences > Projects > Build
  • On Visual Studio for Windows: Tools > Options > Projects and Solutions > Build and Run

On Visual Studio Windows you also want to add -v -v -v -v to the mtouch additional arguments by right-clicking the project in the solution explorer and selecting Properties.
Note: this is done automatically on Visual Studio for Mac when the log verbosity is set to diagnostic.

Hi @dalexsoto ,

Please see the attached log.
I have masked out certain things pertaining to our proprietary terms. and I hope I did not mask out any of the diagnostic log in the process. Do let me know if I have accidentally tinkered the other part of the logs.

log-macos.txt

Looking forward to your help.

Note: Deploying from my Visual Studio on Windows does not have this problem, but deploying from Visual Studio on Windows from a colleague PC results in the issue described.

Hello @imRichardNg

Look like for some reason, System.Memory is being incorrectly resolved in to the Facade assembly but not to the actual assembly with the implementation.

I tried to reproduce myself by bringing the assembly from NuGet but I was not able to reproduce, one difference tho is that you seem to be using a preview assembly from NuGet, any particular reason for this? Could you try using the stable package of System.Memory?

/Users/richard/dev/src/SGV/packages/System.Memory.4.5.0-preview2-26130-01/lib/netstandard2.0/System.Memory.dll

Re: System.Memory. Here's a related issue: https://github.com/xamarin/xamarin-macios/issues/4168

Hello @dalexsoto

Sorry for the late reply.

I have no idea why original source use the preview version, probably because the stable version wasn't out.
Anyway we tried changing to the stable version.
The same errors still occur.

@imRichardNg Can you update to the latest 7.5.4 version of VS Mac. You should also get an update to the .NET Core runtime. I want to confirm if this resolves the issue for you. Thanks!

@imRichardNg have you tried the version mentioned by @therealjohn ? I will close the issue since we did not get any reply, please do feel free to reopen the issue in the case that what @therealjohn mentioned did not work for you.

@mandel-macaque @therealjohn , I apologise for the extremely late reply to the thread.

I have updated my environment today and the issues seem to be fixed now. The application is built and deployed successfully to my iOS device.

Here's the environment that I am running now:

Visual Studio Community 2017 for Mac
Version 7.6.6 (build 17)
Installation UUID: 1972d8a5-d95a-4b2c-a7b7-da92a3c5c7c9
Runtime:
    Mono 5.12.0.301 (2018-02/4fe3280bba1) (64-bit)
    GTK+ 2.24.23 (Raleigh theme)
    Xamarin.Mac 4.4.1.178 (master / eeaeb7e6)

    Package version: 512000301

NuGet
Version: 4.3.1.4445

.NET Core
Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
    2.1.2
    2.1.0
    2.0.5
SDK: /usr/local/share/dotnet/sdk/2.1.302/Sdks
SDK Versions:
    2.1.302
    2.1.300
    2.1.4
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.12.0/lib/mono/msbuild/15.0/bin/Sdks

Xamarin.Profiler
Version: 1.6.3
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Apple Developer Tools
Xcode 9.4.1 (14161)
Build 9F2000

Xamarin.Mac
Version: 4.6.0.14 (Visual Studio Community)
Hash: 1a6e2786
Branch: 
Build date: 2018-08-28 00:12:06-0400

Xamarin.Android
Version: 9.0.0.20 (Visual Studio Community)
Android SDK: /Users/richard/Library/Developer/Xamarin/android-sdk-macosx
    Supported Android versions:
        7.1 (API level 25)
        8.0 (API level 26)
        8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 27.0.1
SDK Build Tools Version: 27.0.3

Java SDK: /usr
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

Xamarin.iOS
Version: 12.0.0.15 (Visual Studio Community)
Hash: 84552a46
Branch: xcode10
Build date: 2018-09-17 21:54:33-0400

Xamarin Inspector
Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

Build Information
Release ID: 706060017
Git revision: 822323b5f6295b271d4c9bfaca4129f90ec41f38
Build date: 2018-09-18 20:19:40+00
Build branch: release-7.6-xcode10
Xamarin extensions: a83eb4b7ad9174ac2e705f2c4257ecd15688ba97

Operating System
Mac OS X 10.14.0
Darwin 18.0.0 Darwin Kernel Version 18.0.0
    Wed Aug 22 20:13:40 PDT 2018
    root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64

Hello, @imRichardNg.
Are you still using SignalR.Client 1.0.0-preview1-final? If so, can you share your current package versions of System.Memory, System.Buffers, System.IO.Pipelines, System.Threading.Tasks.Extensions?
I'm having runtime exception:
Could not load type of field 'Microsoft.AspNetCore.Sockets.Client.ServerSentEventsTransport:_memoryPool' (0) due to: Could not resolve type with token 01000064 (from typeref, class/assembly System.Buffers.MemoryPool, System.IO.Pipelines, Version=0.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60) assembly:System.IO.Pipelines, Version=0.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60 type:System.Buffers.MemoryPool member:(null) signature:<none> after calling hubConnection.StartAsync(). There are no compile errors, though.
I've tried lots of different version combinations but had no luck, I hope you can help me.

Was this page helpful?
0 / 5 - 0 ratings