Bug 56281 - Could not link Assemblies (MT2001)
Summary: Could not link Assemblies (MT2001)
Status: RESOLVED DUPLICATE of bug 56296
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: master
Hardware: Macintosh Mac OS
: High major
Target Milestone: 15.3
Assignee: Bugzilla
URL:
: 56289 ()
Depends on: 53805
Blocks:
  Show dependency tree
 
Reported: 2017-05-12 11:27 UTC by Paul
Modified: 2017-06-12 09:35 UTC (History)
26 users (show)

Tags: 15.2R
Is this bug a regression?: Yes
Last known good build: Reverting to Mono 4.8.1 fixes it


Attachments
TFS Mac Agent Build Log (436.89 KB, text/plain)
2017-05-16 12:47 UTC, mr.pearce
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 Paul 2017-05-12 11:27:36 UTC
Attempting to build iOS AppStore|iPhone returns back an error:

Debug mode on both iPhone simulator and real device runs fine.

MTOUCH : error MT2001: Could not link assemblies.
    	Method: `System.Void XXXXXXX.Data.IP_Record::set_Gap(System.Boolean)`
    	Assembly: `XXXXXXXXXX, 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 "XXXXXXX.iOS.csproj" -- FAILED.

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

This has happened today, after upgrading to all latest upgrades in stable channel.
Comment 1 Chris 2017-05-12 13:20:07 UTC
Hi, 
more or less the same is happening to me, since updating to the current stables.
Happens when building for Release|IPhone, but works with Debug|Simulator.
Could be a problem of the link SDK assemblies. 

    MTOUCH : error MT2001: Could not link assemblies.
    	Method: `System.String EasierLife.Models.Helpers.EasierLifeHelperModel::get_PhoneNumber()`
    	Assembly: `KinsmenApp, Version=1.0.6341.27125, 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 "EasierLife.iOS.csproj" -- FAILED.

---------------------------------

=== Visual Studio Enterprise 2017 for Mac ===

Version 7.0 (build 3146)
Installation UUID: 81aa51ca-148f-44ef-955c-6fd8a6842857
Runtime:
	Mono 5.0.0.100 (2017-02/9667aa6) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 500000100

=== 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.0/lib/mono/msbuild/15.0/bin/Sdks

=== Xamarin.Profiler ===

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

=== Apple Developer Tools ===

Xcode 8.3.2 (12175)
Build 8E2002

=== Xamarin.iOS ===

Version: 10.10.0.33 (Visual Studio Enterprise)
Hash: 3e5ac5ff
Branch: d15-2
Build date: 2017-05-05 18:11:38-0400

=== Xamarin.Mac ===

Version: 3.4.0.33 (Visual Studio Enterprise)

=== Xamarin.Android ===

Version: 7.3.0.13 (Visual Studio Enterprise)
Android SDK: /Users/reichelt/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.3   (API level 10)
		4.0.3 (API level 15)
		4.4   (API level 19)
		5.0   (API level 21)
		5.1   (API level 22)
		6.0   (API level 23)
		7.1   (API level 25)

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

Java SDK: /usr
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

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

=== Xamarin Inspector ===

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

=== Build Information ===

Release ID: 700003146
Git revision: 7553fda2e327d15807298d444007896e5b975dba
Build date: 2017-05-09 12:12:36-04
Xamarin addins: c3d580752be79fc902422f1d55d1cdc2d8b98799
Build lane: monodevelop-lion-d15-2

=== Operating System ===

Mac OS X 10.12.4
Darwin 16.5.0 Darwin Kernel Version 16.5.0
    Fri Mar  3 16:52:33 PST 2017
    root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64
Comment 2 Chris 2017-05-12 13:29:11 UTC
just did a build with '-v -v -v -v' for more output....

    MTOUCH : error MT2001: Could not link assemblies.
    	Method: `System.String EasierLife.Models.Helpers.EasierLifeHelperModel::get_PhoneNumber()`
    	Assembly: `KinsmenApp, Version=1.0.6341.27125, 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 <f600880ba02c4bfa9f6f865ec45cc869>:0 
      at Mono.Cecil.Cil.CodeReader.ReadAsyncMethodBody (Mono.Cecil.Cil.AsyncMethodBodyDebugInformation async_method) [0x00020] in <f600880ba02c4bfa9f6f865ec45cc869>:0 
      at Mono.Cecil.Cil.CodeReader.ReadCustomDebugInformations (Mono.Cecil.MethodDefinition method) [0x00032] in <f600880ba02c4bfa9f6f865ec45cc869>:0 
      at Mono.Cecil.Cil.CodeReader.ReadDebugInfo () [0x0004d] in <f600880ba02c4bfa9f6f865ec45cc869>:0 
      at Mono.Cecil.Cil.CodeReader.ReadMethodBody () [0x00091] in <f600880ba02c4bfa9f6f865ec45cc869>:0 
      at Mono.Cecil.Cil.CodeReader.ReadMethodBody (Mono.Cecil.MethodDefinition method) [0x00014] in <f600880ba02c4bfa9f6f865ec45cc869>:0 
      at Mono.Cecil.MetadataReader.ReadMethodBody (Mono.Cecil.MethodDefinition method) [0x00000] in <f600880ba02c4bfa9f6f865ec45cc869>:0 
      at Mono.Cecil.MethodDefinition+<>c.<get_Body>b__41_0 (Mono.Cecil.MethodDefinition method, Mono.Cecil.MetadataReader reader) [0x00000] in <f600880ba02c4bfa9f6f865ec45cc869>:0 
      at Mono.Cecil.ModuleDefinition.Read[TItem,TRet] (TRet& variable, TItem item, System.Func`3[T1,T2,TResult] read) [0x00040] in <f600880ba02c4bfa9f6f865ec45cc869>:0 
      at Mono.Cecil.MethodDefinition.get_Body () [0x0002c] in <f600880ba02c4bfa9f6f865ec45cc869>:0 
      at Mono.Linker.Steps.MarkStep.ProcessMethod (Mono.Cecil.MethodDefinition method) [0x00191] in /Users/builder/data/lanes/4691/3e5ac5ff/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/3e5ac5ff/source/xamarin-macios/tools/linker/CoreMarkStep.cs:171 
      at Mono.Linker.Steps.MarkStep.ProcessQueue () [0x00026] in /Users/builder/data/lanes/4691/3e5ac5ff/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/3e5ac5ff/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/3e5ac5ff/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/3e5ac5ff/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/3e5ac5ff/source/xamarin-macios/tools/linker/CoreMarkStep.cs:26 
      at MonoTouch.Tuner.MonoTouchMarkStep.Process (Mono.Linker.LinkContext context) [0x0001e] in /Users/builder/data/lanes/4691/3e5ac5ff/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/3e5ac5ff/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/3e5ac5ff/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/3e5ac5ff/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/3e5ac5ff/source/xamarin-macios/tools/mtouch/Target.cs:551 
      at Xamarin.Bundler.Target.ManagedLink () [0x005ce] in /Users/builder/data/lanes/4691/3e5ac5ff/source/xamarin-macios/tools/mtouch/Target.cs:674 
      at Xamarin.Bundler.Target.ProcessAssemblies () [0x000b4] in /Users/builder/data/lanes/4691/3e5ac5ff/source/xamarin-macios/tools/mtouch/Target.cs:854 
      at Xamarin.Bundler.Application.ProcessAssemblies () [0x00036] in /Users/builder/data/lanes/4691/3e5ac5ff/source/xamarin-macios/tools/mtouch/Application.cs:1355 
      at Xamarin.Bundler.Application.BuildManaged () [0x00002] in /Users/builder/data/lanes/4691/3e5ac5ff/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/3e5ac5ff/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/3e5ac5ff/source/xamarin-macios/tools/mtouch/Application.cs:761 
      at Xamarin.Bundler.Driver.Main2 (System.String[] args) [0x0048b] in /Users/builder/data/lanes/4691/3e5ac5ff/source/xamarin-macios/tools/mtouch/mtouch.cs:1495 
      at Xamarin.Bundler.Driver.Main (System.String[] args) [0x0000f] in /Users/builder/data/lanes/4691/3e5ac5ff/source/xamarin-macios/tools/mtouch/mtouch.cs:1006 
Done building target "_CompileToNative" in project "EasierLife.iOS.csproj" -- FAILED.


Hope that helps finding a solution :-)
Comment 3 Jason Rawlins 2017-05-12 16:35:21 UTC
We are also having this same issue... Debug builds are fine. Release builds are broken..

Latest Xamarin Studio and Visual Studio fail the same..

Changing link behavior to None does allow the build to complete.. Could this be an issue with the latest Mono??
Comment 4 Paul 2017-05-12 16:49:48 UTC
Something you can do - revert back to Mono 4.8.1. It works and AppStore has accepted the build. 

Go to Visual Studio -> Preferences -> Projects -> .NET Runtimes  (in VS for Mac). For those who is desperate and need you build ASAP, it is your life saver.
Comment 5 Jason Rawlins 2017-05-12 17:18:47 UTC
Thanks Paul.. Unfortunately for me that shows a different issue..

/Users/JRawlins/github/XXXXXXX/Mobile/iOS/CustomRenderers/RoundedCornerImageRenderer.cs(33,33): Error CS1070: The type `System.Drawing.Color' has been forwarded to an assembly that is not referenced. Consider adding a reference to assembly `OpenTK-1.0, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' (CS1070) (iOS)

/Users/JRawlins/github/XXXXXXX/Mobile/iOS/CustomRenderers/RoundedCornerImageRenderer.cs(39,39): Error CS0584: Internal compiler error: Assembly 'OpenTK-1.0, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' is a missing assembly and does not support the requested operation. (CS0584) (iOS)

Can't add the OpenTK assembly because that starts up a whole more issues..

Not sure why this is happening as compilation was fine before under 4.8.1..
Comment 6 Brendan Zagaeski (Xamarin Team, assistant) 2017-05-12 18:08:06 UTC
*** Bug 56289 has been marked as a duplicate of this bug. ***
Comment 7 Sebastien Pouliot 2017-05-12 20:20:17 UTC
This is likely a duplicate of https://bugzilla.xamarin.com/show_bug.cgi?id=56296

Can you attach the full build logs (with "-v -v -v -v") so we can confirm it's the same issue (and not a different one that looks similar) ? thanks!
Comment 8 mr.pearce 2017-05-16 12:47:11 UTC
Created attachment 22203 [details]
TFS Mac Agent Build Log

Hi i have this Error On my TFS Mac Build Agent since the 15.2 Visual Studio / VS for Mac (7.0 - Build 3146) Update.

On my Mac is the latest Visual Studio for Mac Version (7.0 - Build 3146)
The Build Configuration is AppStore|IPhone (Debug|IPhone is building fine)
Both have the same settings (except provisioning profiles)

here is the TFS Build Log
Comment 9 Sebastien Pouliot 2017-05-16 12:50:57 UTC
@mr.pierce your issue is definitively #56296

2017-05-16T12:22:01.6763680Z 			Target XamlC:
2017-05-16T12:22:01.6789460Z 				Compiling Xaml
2017-05-16T12:22:01.6814300Z 				Assembly: obj/Release/Shared.dll

This bugs remains open so we can validate the previously reported cases are also the same bug (and not something else).
Comment 10 Rendy Del Rosario 2017-05-18 16:38:41 UTC
If you are using XAML Compilation

Try this:

#if DEBUG
	[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
#else
#endif
Comment 11 drungrin 2017-05-24 18:12:37 UTC
I'm having exactly the same issue. No Xamarin.Forms or XAML involved, the project is native.

> Projects/<**omitted**>-mobi-app/**omitted**Mobi/**omitted**Mobi.iOS/obj/iPhone/Release/mtouch-cache/64/PreBuild using mode 'SDKOnly'
> MTOUCH: error MT2001: Could not link assemblies.
> 			Method: `System.Void **omitted**Mobi.ViewModels.**omitted**ViewModel/ItemViewModel/<>c::.cctor()`
> 			Assembly: `**omitted**Mobi, Version=1.0.6353.26345, Culture=neutral, PublicKeyToken=null`
> 		Reason: Value cannot be null.
> 		Parameter name: instruction
> 			Value cannot be null.
> 		Parameter name: instruction
> 	Task "MTouch" execution -- FAILED
> 	Done building target "_CompileToNative" in project "/Users/michel/Projects/**omitted**-mobi-app/**omitted**Mobi/**omitted**Mobi.iOS/**omitted**Mobi.iOS.csproj".-- FAILED
Comment 12 Daniel 2017-05-30 13:59:32 UTC
Same issue here:

My setup:=== Visual Studio Professional 2017 for Mac ===

Version 7.0.1 (build 24)
Installation UUID: 5df97807-9ab1-44cf-8085-9d15d57d9e2e
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: Not installed
SDK: Not installed
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

=== Apple Developer Tools ===

Xcode 8.3.2 (12175)
Build 8E2002

=== Xamarin.Mac ===

Version: 3.4.0.36 (Visual Studio Professional)

=== 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.Android ===

Version: 7.3.1.2 (Visual Studio Professional)
Android SDK: /Users/danielklokov/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.1 (API level 16)
		4.2 (API level 17)
		4.3 (API level 18)
		4.4 (API level 19)
		5.0 (API level 21)
		5.1 (API level 22)
		6.0 (API level 23)
		7.0 (API level 24)
		7.1 (API level 25)

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

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

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

=== Xamarin Inspector ===

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

=== 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.5
Darwin 16.6.0 Darwin Kernel Version 16.6.0
    Fri Apr 14 16:21:16 PDT 2017
    root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64
Comment 13 Paul DiPietro [MSFT] 2017-05-30 21:59:14 UTC
*** Bug 56974 has been marked as a duplicate of this bug. ***
Comment 14 Derek Foulk 2017-05-30 22:07:29 UTC
We encountered this issue as well (see bug 56974).

Temporary workaround that we used (to keep XAML compilation for Android):

#if __ANDROID__

using Xamarin.Forms.Xaml;

[assembly: XamlCompilation(XamlCompilationOptions.Compile)]

#endif
Comment 15 ari@kolibr.is 2017-05-31 16:19:24 UTC
Have this same error after upgrading Xamarin. Tried to turn off Xaml Compilation as suggested without success. Downgrading to Mono 4.8.1 would be fine but I am unable to do that in our build-pipe which uses msbuild to build it. Is there any workaround?
Comment 16 Chris Charabaruk 2017-05-31 18:53:10 UTC
Also finding this to happen for iOS builds. Debug builds work, any builds where the linker is set to work fail. For our project we find that it's being triggered by a getter for an autoproperty in a POCO class. This happens both building locally on a Mac or using Windows with connection to MacInCloud.

Downgrading to Mono 4.8.1 won't work for us because we neither control what's installed on our MacInCloud systems nor in the build chain we're leveraging for automated builds.
Comment 17 Chris Charabaruk 2017-05-31 19:24:21 UTC
Okay, looks to actually be working for builds run from Windows. Checked with our other developer -- mtouch on the Mac machine is 10.10.0.33 (d15-2: 3e5ac5ff). On MacInCloud it is 10.10.0.36 (d15-2: d2270eec). Since we can't run shell commands directly on the build chain I can't really determine what version of the mtouch tool is installed there, but builds _are_ succeeding with linking enabled on it.
Comment 18 Rolf Bjarne Kvinge [MSFT] 2017-06-01 14:34:19 UTC
I'm closing this as a duplicate of bug #56296, since that's what it looks like for now.

@Paul: if you can provide the complete build log, please reopen the bug and we'll have a look to make sure it's really is a duplicate.

@everybody else: this error is quite generic, and there can be many causes. Everybody should open their own bug, so that we can investigate each issue separately without getting confused when multiple things happen concurrently in the same bug. Opening a new bug also allows you to make the bug private, in case you don't want the build log (or any other data) public.

*** This bug has been marked as a duplicate of bug 56296 ***
Comment 19 dmitri.toropov 2017-06-01 15:14:26 UTC
No, this is either not a duplicate for #56296 or #56296 is not relevant to Xamarin Forms. I have the same issue in a native iOS project with no Xamarin Forms whatsoever. As already reported above, downgrading to Mono 4.8.1 solves the issue.
Comment 20 Denis Gordin 2017-06-01 15:26:04 UTC
I agree with Dmitri Toropov.
I have the issue and I don't use Forms either.
Comment 21 Derek Foulk 2017-06-01 16:26:33 UTC Comment hidden (obsolete)
Comment 22 Rolf Bjarne Kvinge [MSFT] 2017-06-01 16:29:02 UTC Comment hidden (obsolete)
Comment 23 Derek Foulk 2017-06-01 16:30:17 UTC Comment hidden (obsolete)
Comment 24 Martin 2017-06-12 09:35:56 UTC
Hello,

how to use Mono 4.8.1 with VSTS ?

thank you