Bug 44701 - Could not link assemblies. Reason: Object reference not set to an instance of an object iOS 10.0 Xamarin
Summary: Could not link assemblies. Reason: Object reference not set to an instance of...
Status: VERIFIED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll (show other bugs)
Version: XI 10.0 (iOS10)
Hardware: PC Mac OS
: Normal normal
Target Milestone: (C9)
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2016-09-23 19:30 UTC by Rafael Nicolett
Modified: 2018-01-29 07:36 UTC (History)
8 users (show)

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


Attachments
Could not link assemblies. Reason: Object reference not set to an instance of an object (6.71 MB, text/rtf)
2016-09-23 19:30 UTC, Rafael Nicolett
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:
VERIFIED FIXED

Description Rafael Nicolett 2016-09-23 19:30:15 UTC
Created attachment 17719 [details]
Could not link assemblies. Reason: Object reference not set to an instance of an object

I have problems when build iOS Releases with Link SDK Only Assemblies is activated:

Could not link assemblies. Reason: Object reference not set to an instance of an object
Comment 1 Sebastien Pouliot 2016-09-23 19:33:25 UTC
Thanks, but we'll need more than logs. Can you share a test case (or your application) so we can duplicate the issue ?
Comment 2 Rafael Nicolett 2016-09-23 19:58:08 UTC
How could I share you a case testing?

It's my first post of bug Xamarin, could help me to send you more information?
Comment 3 Sebastien Pouliot 2016-09-23 20:08:56 UTC
@Rafael, you can attach a small* test case directly to the bug report. You can mark is as private so it won't be visible publicly (but only to Xamarin/MS employees).

* if the test case can not fit into bugzilla limit you can give us a link (to dropbox, google drive...) where we can download it. Again you can put the comment as private so the link won't be visible publicly.
Comment 4 Rafael Nicolett 2016-09-23 20:50:41 UTC
@Sebastien

I can add you to my team in the Visual Studio Online Git to access the project, we can do this?
Comment 5 Sebastien Pouliot 2016-09-23 21:00:04 UTC
Never tried it (mac only here), but github and other worked fine so I assume this one would too.
Comment 6 Rafael Nicolett 2016-09-23 21:03:02 UTC
Ok it's git user into Visual Studio Online platform, you send e-mail to I add you into our team?
Comment 7 Claudio Redi 2016-09-26 18:23:31 UTC
@Sebastien, please share your finds here as I'm also looking for a solution for this.
Comment 8 Sebastien Pouliot 2016-09-27 12:50:05 UTC
I can duplicate the issue using Rafael's project. I'll update the bug report once fixes becomes available. Thanks!
Comment 9 Sebastien Pouliot 2016-09-27 14:05:13 UTC
GoogleConversionTracking.Unified.dll contains some extra, unneeded code, generated by the C# compiler*, e.g.

IL_002f: stloc.0
IL_0030: ldloc.0

which the binding optimizer did not expect.


* maybe just lacking `/optimize` with an old `csc` compiler. Mono's `mcs` never generated that code pattern.

The workaround (for the current stable XI) is to add

> --linkskip=GoogleConversionTracking.Unified

to your *Additional mtouch arguments* of your main project. That will turn off linking only for that assembly (which does not have a lot of managed code to optimize anyway).
Comment 10 Claudio Redi 2016-09-27 14:19:53 UTC
@Sebastien, good find :) Do I have any way to know what's the offensive assembly in my case? I don't see that dll in my project.
Comment 11 Sebastien Pouliot 2016-09-27 15:30:32 UTC
@Claudio Right now* the easiest way would be to do a "binary search" using `--linkskip=XXX` on your binding assemblies.

* I'm looking (separately) into adding more specific errors for such errors.
Comment 12 Sebastien Pouliot 2016-09-27 16:16:36 UTC
PR (master) https://github.com/xamarin/xamarin-macios/pull/900
Comment 13 Sebastien Pouliot 2016-09-27 20:35:15 UTC
Merged in xamarin-macios/master commit da60263a0a94f38d56d554eab90962beb5283b63
Comment 14 Claudio Redi 2016-09-27 20:53:00 UTC
Thanks @Sebastien, I was able to find the offending assembly. Thanks for your assistance.
Comment 17 Saurabh 2016-10-06 09:00:25 UTC
Using attached dll in comment#16, I can also reproduce this Issue with stable builds (XS 6.1.1.15 + XI 10.0.1.10). This is the build output for the same: https://gist.github.com/saurabh360/cca37acea52ffcb380319c67d7e7f447

I have checked the same Issue with latest master builds (XS 6.2.0.750, XI 10.1.0.135) and observed that template application having .dll added, build successfully.
Build Output: https://gist.github.com/saurabh360/a1fe2dac34313374c4789f285595290f

Environment Info: https://gist.github.com/saurabh360/8a533503efa324b3ffaaaff96d192c22
Comment 18 jon.hunt 2016-12-12 17:11:33 UTC
Can you explain with some more detail on what this means?

the easiest way would be to do a "binary search" using `--linkskip=XXX` on your binding assemblies.

How do I do a binary search for linkskip=XXX and what are the binding assemblies? Sorry I'm getting the same crash in MonoTouch trying to build my XI app.
Comment 19 Rendy Del Rosario 2017-05-18 16:39:30 UTC
If you are using XAML Compilation

Try this:

#if DEBUG
	[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
#else
#endif
Comment 20 chetansrm 2018-01-29 07:36:36 UTC
Hey! I am also facing the same issue.What I doing I am explaining you as below.
I have created a standard library for realmDB and I am adding it as a project like named "stdProject" in separate project named "XProject"(I have also add refrence of standard lib). But whenever I create object of "stdProject" in viewDidLoad of "XProject" always I am getting the compile time error "MTOUCH : error MT2001: Could not link assemblies. Reason: Object reference not set to an instance of an object".
Note the one thing if keep the "stdProject" inside the "XProject then successfully  I am getting the result"
I am using visiual studio for mac 7.3.3(build)