Bug 58378 - MTouch error MT2001 when building from Visual Studio for Mac in Release or Ad-hoc mode
Summary: MTouch error MT2001 when building from Visual Studio for Mac in Release or Ad...
Status: RESOLVED DUPLICATE of bug 56296
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: Future Cycle (TBD)
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-07-25 16:36 UTC by me
Modified: 2017-08-31 23:19 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Build Log showing error (2.40 MB, text/plain)
2017-07-25 19:50 UTC, me
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 56296

Description me 2017-07-25 16:36:06 UTC
The Visual Studio build fails in Ad-Hoc or Release mode with the error below. It succeeds on both my device and the simulator in Debug mode. I can zip up the whole solution and send it to you if it will help.


MobileApp.Client.iOS/bin/iPhone/Ad-Hoc/MobileApp.Client.iOS.exe -v -v 
    MTOUCH : error MT2001: Could not link assemblies.
    	Method: `System.Void MobileApp.Messages.Order::MergeFrom(MobileApp.Messages.Order)`
    	Assembly: `MobileApp.Client.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null`
    Reason: Value cannot be null.
    Parameter name: instruction
    	Value cannot be null.
    Parameter name: instruction
Done building target "_CompileToNative" in project "MobileApp.Client.iOS.csproj" -- FAILED.

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

Build FAILED.
Comment 1 me 2017-07-25 17:10:33 UTC
The build succeeds in Visual Studio for Windows.
Comment 2 Sebastien Pouliot 2017-07-25 18:26:20 UTC
This looks like a known issue with `xamlc` (part of Xamarin.Forms).
https://bugzilla.xamarin.com/show_bug.cgi?id=56296


Could you attach your full build logs and all version information ?

To get full build logs just set the log verbosity to diagnostic at the following locations:
- On Visual Studio for Mac: Preferences > Projects > Build

Easiest way to get exact version information on Visual Studio for Mac: "Visual Studio" menu, "About Visual Studio" item, "Show Details" button.

Then copy/paste the version information (you can use the "Copy Information" button).
Comment 3 me 2017-07-25 19:16:25 UTC
Version info:

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

Version 7.0.1 (build 24)
Installation UUID: 80bdf4df-6962-44ea-9d7f-e27c65860cbf
Runtime:
	Mono 5.0.1.1 (2017-02/5077205) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 500010001

=== NuGet ===

Version: 4.0.0.2323

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
SDK: /usr/local/share/dotnet/sdk/1.0.3/Sdks
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.0.1/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

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

=== Xamarin.Android ===

Version: 7.3.1.2 (Visual Studio Professional)
Android SDK: /Users/jblackburn/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		6.0 (API level 23)

SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.5
SDK Build Tools Version: 25.0.3

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

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

=== Apple Developer Tools ===

Xcode 8.3.3 (12175.1)
Build 8E3004b

=== Xamarin.iOS ===

Version: 10.10.0.36 (Visual Studio Professional)
Hash: d2270eec
Branch: d15-2
Build date: 2017-05-22 16:30:53-0400

=== Xamarin Inspector ===

Version: 1.2.2
Hash: b71b035
Branch: d15-1
Build date: Fri, 21 Apr 2017 17:57:12 GMT

=== Xamarin.Mac ===

Version: 3.4.0.36 (Visual Studio Professional)

=== Build Information ===

Release ID: 700010024
Git revision: 7ab1ca2ced6f584e56b7a0d4d321d00775cd95c9
Build date: 2017-05-19 05:44:51-04
Xamarin addins: 08d17158f3365beee5e60f67999e607cce4b3f93
Build lane: monodevelop-lion-d15-2

=== Operating System ===

Mac OS X 10.12.6
Darwin 16.7.0 Darwin Kernel Version 16.7.0
    Thu Jun 15 17:36:27 PDT 2017
    root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64
Comment 4 me 2017-07-25 19:50:56 UTC
Created attachment 23797 [details]
Build Log showing error
Comment 5 Vincent Dondain [MSFT] 2017-08-31 23:19:52 UTC
```
MTOUCH : error MT2001: Could not link assemblies.
        Method: `System.Void MobileApp.Messages.Order::MergeFrom(MobileApp.Messages.Order)`
        Assembly: `MobileApp.Client.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null`
    Reason: Value cannot be null.
    Parameter name: instruction
    --- inner exception
    System.ArgumentNullException: Value cannot be null.
    Parameter name: instruction
      at Mono.Cecil.Cil.InstructionOffset..ctor (Mono.Cecil.Cil.Instruction instruction) [0x00003] in <4fabf1217b0249ea867af084ea2f11eb>:0 
      at Mono.Cecil.Cil.CodeReader.ReadAsyncMethodBody (Mono.Cecil.Cil.AsyncMethodBodyDebugInformation async_method) [0x00020] in <4fabf1217b0249ea867af084ea2f11eb>:0 
      at Mono.Cecil.Cil.CodeReader.ReadCustomDebugInformations (Mono.Cecil.MethodDefinition method) [0x00032] in <4fabf1217b0249ea867af084ea2f11eb>:0 
      at Mono.Cecil.Cil.CodeReader.ReadDebugInfo () [0x0004d] in <4fabf1217b0249ea867af084ea2f11eb>:0 
      at Mono.Cecil.Cil.CodeReader.ReadMethodBody () [0x00091] in <4fabf1217b0249ea867af084ea2f11eb>:0 
      at Mono.Cecil.Cil.CodeReader.ReadMethodBody (Mono.Cecil.MethodDefinition method) [0x00014] in <4fabf1217b0249ea867af084ea2f11eb>:0 
      at Mono.Cecil.MetadataReader.ReadMethodBody (Mono.Cecil.MethodDefinition method) [0x00000] in <4fabf1217b0249ea867af084ea2f11eb>:0 
      at Mono.Cecil.MethodDefinition+<>c.<get_Body>b__41_0 (Mono.Cecil.MethodDefinition method, Mono.Cecil.MetadataReader reader) [0x00000] in <4fabf1217b0249ea867af084ea2f11eb>:0 
      at Mono.Cecil.ModuleDefinition.Read[TItem,TRet] (TRet& variable, TItem item, System.Func`3[T1,T2,TResult] read) [0x00040] in <4fabf1217b0249ea867af084ea2f11eb>:0 
      at Mono.Cecil.MethodDefinition.get_Body () [0x0002c] in <4fabf1217b0249ea867af084ea2f11eb>:0 
      at Mono.Linker.Steps.MarkStep.ProcessMethod (Mono.Cecil.MethodDefinition method) [0x00191] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:1046 
      at Xamarin.Linker.Steps.CoreMarkStep.ProcessMethod (Mono.Cecil.MethodDefinition method) [0x00060] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/tools/linker/CoreMarkStep.cs:171 
      at Mono.Linker.Steps.MarkStep.ProcessQueue () [0x00026] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:150 
      at Mono.Linker.Steps.MarkStep.Process () [0x0001e] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:115 
      at Mono.Linker.Steps.MarkStep.Process (Mono.Linker.LinkContext context) [0x0000f] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:60 
      at Xamarin.Linker.Steps.MobileMarkStep.Process (Mono.Linker.LinkContext context) [0x00003] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/tools/linker/MobileMarkStep.cs:33 
      at Xamarin.Linker.Steps.CoreMarkStep.Process (Mono.Linker.LinkContext context) [0x00018] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/tools/linker/CoreMarkStep.cs:26 
      at MonoTouch.Tuner.MonoTouchMarkStep.Process (Mono.Linker.LinkContext context) [0x0001e] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/tools/linker/MonoTouch.Tuner/MonoTouchMarkStep.cs:36 
      at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x00027] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/external/linker/linker/Mono.Linker/Pipeline.cs:118 
      at MonoTouch.Tuner.Linker.Process (MonoTouch.Tuner.LinkerOptions options, MonoTouch.Tuner.MonoTouchLinkContext& context, System.Collections.Generic.List`1[Mono.Cecil.AssemblyDefinition]& assemblies) [0x000dd] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/tools/mtouch/Tuning.cs:82 
    ---
      at MonoTouch.Tuner.Linker.Process (MonoTouch.Tuner.LinkerOptions options, MonoTouch.Tuner.MonoTouchLinkContext& context, System.Collections.Generic.List`1[Mono.Cecil.AssemblyDefinition]& assemblies) [0x002a9] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/tools/mtouch/Tuning.cs:111 
      at Xamarin.Bundler.Target.LinkAssemblies (System.Collections.Generic.List`1[Mono.Cecil.AssemblyDefinition]& assemblies, System.String output_dir, System.Collections.Generic.IEnumerable`1[T] sharedCodeTargets) [0x00257] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/tools/mtouch/Target.cs:551 
      at Xamarin.Bundler.Target.ManagedLink () [0x005ce] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/tools/mtouch/Target.cs:674 
      at Xamarin.Bundler.Target.ProcessAssemblies () [0x000b4] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/tools/mtouch/Target.cs:854 
      at Xamarin.Bundler.Application.ProcessAssemblies () [0x00036] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/tools/mtouch/Application.cs:1355 
      at Xamarin.Bundler.Application.BuildManaged () [0x00002] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/tools/mtouch/Application.cs:809 
      at Xamarin.Bundler.Application.<BuildAll>m__7 (Xamarin.Bundler.Application v) [0x00001] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/tools/mtouch/Application.cs:761 
      at System.Collections.Generic.List`1[T].ForEach (System.Action`1[T] action) [0x00024] in /private/tmp/source-mono-2017-02/bockbuild-2017-02/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/mscorlib/system/collections/generic/list.cs:564 
      at Xamarin.Bundler.Application.BuildAll () [0x00067] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/tools/mtouch/Application.cs:761 
      at Xamarin.Bundler.Driver.Main2 (System.String[] args) [0x0048b] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/tools/mtouch/mtouch.cs:1495 
      at Xamarin.Bundler.Driver.Main (System.String[] args) [0x0000f] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/tools/mtouch/mtouch.cs:1006 
    The command exited with code 1.
```

This indeed looks like the same cecil issue.

You're using Xamarin.Forms.2.3.4.231, later versions should include the fix.

*** This bug has been marked as a duplicate of bug 56296 ***