Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
I'm getting a NullReferenceException in CreateStronglyTypedExportFactoryFactory in /Library/Frameworks/Xamarin.iOS.framework/Versions/18.104.22.168/src/mono/mcs/class/System.ComponentModel.Composition.4.5/src/ComponentModel/System/ComponentModel/Composition/ReflectionModel/ExportfactoryCreator.cs
The exception happens when it tries to call
genericMethod = _createStronglyTypedExportFactoryOfTM.MakeGenericMethod(exportType, metadataViewType);
The member variable is null. This only happens if Link SDK or Link All Assemblies. If Link None, this code works fine. This makes sense because the member variable is initialized by reflection:
private static readonly MethodInfo _createStronglyTypedExportFactoryOfTM = typeof(ExportFactoryCreator).GetMethod("CreateStronglyTypedExportFactoryOfTM", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
As a workaround, I am able to set --linkskip=System.ComponentModel.Composition.
The workaround is fine - and might still be needed for other cases beyond the one we can deal with, e.g.
* ExportFactoryCreator.CreateStronglyTypedExportFactoryOfT 
* ExportFactoryCreator.CreateStronglyTypedExportFactoryOfTM 
* ExportServices.CreateStronglyTypedLazyOfT 
* ExportServices.CreateStronglyTypedLazyOfTM 
* ExportServices.CreateSemiStronglyTypedLazy 
^ Those will (or are) be handled automatically by the linker in future  (or existing ) versions of XI.
OTOH MEF is quite dynamic in nature so overall YMMV, i.e. there are other cases that cannot be predicted.
Fixed in maccore/master a6d6a7077cbfc1f484e8bafd604c7a8db56a7d47
QA: unit tests added in the same revision