Bug 22974 - Error MM2001 when an assembly contains certain code containing async lambdas and generic methods.
Summary: Error MM2001 when an assembly contains certain code containing async lambdas ...
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: mmp ()
Version: 1.10.0
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Chris Hamons
Depends on:
Reported: 2014-09-14 04:38 UTC by bugzilla
Modified: 2014-12-03 18:22 UTC (History)
3 users (show)

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

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:

Description bugzilla 2014-09-14 04:38:47 UTC
Reproduce the problem by creating a new Xamarin.Mac Document Project in Xamarin Studio, switching the target framework to .NET 4.5, and adding the following code:

using System;
using System.Threading.Tasks;

public class MmpCrash
	static void TestMethod<T>(Action<Action> subscribe)
		Task<bool> task = null;
		subscribe(() => {
			Task result = null;
			task = Then(task, async b => { await result; return true; });
	static Task<T2> Then<T1, T2>(Task<T1> first, Func<T1, Task<T2>> next)
		return null;

If you move the "Task<bool> task = null;" line into the subscribe lambda, it prevents mmp from crashing.  Otherwise, the error output looks something like this:

Merging Mono Runtime into app bundle
/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/bin/mmp -linksdkonly "-minos=10.6" --sdkroot "/Applications/Xcode.app/Contents/Developer" -o "/Users/andrew/Projects/XamarinMacDocumentProject/XamarinMacDocumentProject/bin/Release" -n "XamarinMacDocumentProject" --profile "4.5" -a "/Library/Frameworks/Mono.framework/Versions/3.8.0/lib/mono/4.5/System.dll" -a "/Library/Frameworks/Mono.framework/Versions/3.8.0/lib/mono/4.5/System.Xml.dll" -a "/Library/Frameworks/Mono.framework/Versions/3.8.0/lib/mono/4.5/System.Core.dll" -a "/Library/Frameworks/Mono.framework/Versions/3.8.0/lib/mono/4.5/System.Xml.Linq.dll" -a "/Library/Frameworks/Mono.framework/Versions/3.8.0/lib/mono/4.5/System.Drawing.dll" -a "/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/XamMac.dll" -a "/Library/Frameworks/Mono.framework/Versions/3.8.0/lib/mono/4.5/System.Core.dll" "/Users/andrew/Projects/XamarinMacDocumentProject/XamarinMacDocumentProject/bin/Release/XamarinMacDocumentProject.exe"
error MM2001: Could not link assemblies. Reason: Object reference not set to an instance of an object
Comment 1 Chris Hamons 2014-09-15 10:05:43 UTC
I'm having some trouble reproducing this issue. Are you running this in a classic or unified project? What license do you have? Could you just zip up a project reproducing this issue and attach it?
Comment 3 Parmendra Kumar 2014-11-24 08:34:31 UTC
I have checked this issue by using the attached project in comment 2, and I am also using business license but application launch successfully without any error as shown in screencast : http://screencast.com/t/fPMZCGfUtLqN

Could you please try it with latest stable builds and let us know if you are still getting this issue?

Note : I have checked this issue with Xcode 5.1.1 and Xcode 6.1 but it works fine.

Environment info :
=== Xamarin Studio ===

Version 5.5.4 (build 14)
Installation UUID: 45555ffd-f3f0-4f29-9543-e369d711ab7d
	Mono 3.10.0 ((detached/92c4884)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 310000031

=== Xamarin.Android ===

Version: (Business Edition)
Android SDK: /Users/xamarin77/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		3.2    (API level 13)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Apple Developer Tools ===

Xcode 6.1 (6604)
Build 6A1052d

=== Xamarin.iOS ===

Version: (Business Edition)
Hash: 840a925
Build date: 2014-11-16 21:03:22-0500

=== Xamarin.Mac ===

Version: (Business Edition)

=== Build Information ===

Release ID: 505040014
Git revision: 0ba6e4604b0c07b002498251c20bde8a265b13be
Build date: 2014-11-11 15:38:26-05
Xamarin addins: 8ee37a13f91f85d350eeecbab99dff85d24d02dd

=== Operating System ===

Mac OS X 10.9.5
Darwin Xamarin77s-Mac-mini.local 13.4.0 Darwin Kernel Version 13.4.0
    Sun Aug 17 19:50:11 PDT 2014
    root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
Comment 4 Chris Hamons 2014-12-03 18:22:29 UTC
This appears fixed in the latest stable, both your attached example and one I created myself. Please reopen if you run into this again.