Bug 60176 - mtouch error "Could not link assemblies" on System.Reflection.RuntimeParameterInfo
Summary: mtouch error "Could not link assemblies" on System.Reflection.RuntimeParamete...
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools ()
Version: master
Hardware: PC Windows
: --- normal
Target Milestone: Future Cycle (TBD)
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-10-13 11:16 UTC by panico
Modified: 2017-10-24 09:04 UTC (History)
3 users (show)

Tags:
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:
Status:
RESOLVED FIXED

Description panico 2017-10-13 11:16:42 UTC
Following error when Linking All or SDK Framework only

Microsoft Visual Studio Enterprise 2017 
Version 15.3.5
VisualStudio.15.Release/15.3.5+26730.16
Microsoft .NET Framework
Version 4.7.02046


Xamarin   4.7.9.45 (bd7e3753c)
Xamarin.Android SDK   7.4.5.1 (fb018c5)
Xamarin.Android Reference Assemblies and MSBuild support.
Xamarin.iOS and Xamarin.Mac SDK   11.0.0.0 (152b654)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Newest stable channel updates on Mac as of today

mtouch arguments:
--linkskip=mscorlib --linkskip=System.Core --linkskip=System.Linq --linkskip=System.Linq.Expressions --linkskip=System.Runtime.Serialization --linkskip=System.Collections --linkskip=AutoMapper --linkskip=AutoMapper.Collection --linkskip=Microsoft.Practices.Unity --linkskip=IFM --linkskip=IFM.iOS --linkskip=HtmlAgilityPack --linkskip=ImageCircle.Forms.Plugin.iOS --linkskip=ImageCircle.Forms.Plugin.Abstractions --linkskip=MR.Gestures.iOS

-v -v -v -v Output:

 error : Could not link assemblies.
2>  	Type: `System.Reflection.RuntimeParameterInfo` (Aufgaben-ID: 165)
2>  	Assembly: `mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e` (Aufgaben-ID: 165)
2>  Reason: Object reference not set to an instance of an object (Aufgaben-ID: 165)
2>  --- inner exception (Aufgaben-ID: 165)
2>  System.NullReferenceException: Object reference not set to an instance of an object (Aufgaben-ID: 165)
2>    at MonoTouch.Tuner.MonoTouchMarkStep.MarkMethod (Mono.Cecil.MethodReference reference) [0x0004f] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/linker/MonoTouch.Tuner/MonoTouchMarkStep.cs:105  (Aufgaben-ID: 165)
2>    at Mono.Linker.Steps.MarkStep.MarkMethodCollection (System.Collections.IEnumerable methods) [0x00017] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:1163  (Aufgaben-ID: 165)
2>    at Mono.Linker.Steps.MarkStep.MarkMethods (Mono.Cecil.TypeDefinition type) [0x0000b] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:1157  (Aufgaben-ID: 165)
2>    at Xamarin.Linker.Steps.MobileMarkStep.MarkMethods (Mono.Cecil.TypeDefinition type) [0x0000b] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/linker/MobileMarkStep.cs:123  (Aufgaben-ID: 165)
2>    at Mono.Linker.Steps.MarkStep.ApplyPreserveInfo (Mono.Cecil.TypeDefinition type) [0x0004a] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:1102  (Aufgaben-ID: 165)
2>    at Mono.Linker.Steps.MarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x001ee] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:607  (Aufgaben-ID: 165)
2>    at Xamarin.Linker.Steps.MobileMarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x00001] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/linker/MobileMarkStep.cs:71  (Aufgaben-ID: 165)
2>    at Xamarin.Linker.Steps.CoreMarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x00046] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/linker/CoreMarkStep.cs:156  (Aufgaben-ID: 165)
2>    at MonoTouch.Tuner.MonoTouchMarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x00001] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/linker/MonoTouch.Tuner/MonoTouchMarkStep.cs:84  (Aufgaben-ID: 165)
2>    at Mono.Linker.Steps.MarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x0007d] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:566  (Aufgaben-ID: 165)
2>    at Xamarin.Linker.Steps.MobileMarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x00001] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/linker/MobileMarkStep.cs:71  (Aufgaben-ID: 165)
2>    at Xamarin.Linker.Steps.CoreMarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x00046] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/linker/CoreMarkStep.cs:156  (Aufgaben-ID: 165)
2>    at MonoTouch.Tuner.MonoTouchMarkStep.MarkType (Mono.Cecil.TypeReference reference) [0x00001] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/linker/MonoTouch.Tuner/MonoTouchMarkStep.cs:84  (Aufgaben-ID: 165)
2>    at Mono.Linker.Steps.MarkStep.InitializeType (Mono.Cecil.TypeDefinition type) [0x0005b] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:94  (Aufgaben-ID: 165)
2>    at Mono.Linker.Steps.MarkStep.InitializeAssembly (Mono.Cecil.AssemblyDefinition assembly) [0x00025] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:81  (Aufgaben-ID: 165)
2>    at Mono.Linker.Steps.MarkStep.Initialize () [0x00016] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:73  (Aufgaben-ID: 165)
2>    at Mono.Linker.Steps.MarkStep.Process (Mono.Linker.LinkContext context) [0x00008] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/external/linker/linker/Mono.Linker.Steps/MarkStep.cs:66  (Aufgaben-ID: 165)
2>    at Xamarin.Linker.Steps.MobileMarkStep.Process (Mono.Linker.LinkContext context) [0x00001] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/linker/MobileMarkStep.cs:33  (Aufgaben-ID: 165)
2>    at Xamarin.Linker.Steps.CoreMarkStep.Process (Mono.Linker.LinkContext context) [0x00017] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/linker/CoreMarkStep.cs:26  (Aufgaben-ID: 165)
2>    at MonoTouch.Tuner.MonoTouchMarkStep.Process (Mono.Linker.LinkContext context) [0x0001d] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/linker/MonoTouch.Tuner/MonoTouchMarkStep.cs:36  (Aufgaben-ID: 165)
2>    at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) [0x00023] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/external/linker/linker/Mono.Linker/Pipeline.cs:128  (Aufgaben-ID: 165)
2>    at MonoTouch.Tuner.Linker.Process (MonoTouch.Tuner.LinkerOptions options, MonoTouch.Tuner.MonoTouchLinkContext& context, System.Collections.Generic.List`1[Mono.Cecil.AssemblyDefinition]& assemblies) [0x000e0] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/mtouch/Tuning.cs:82  (Aufgaben-ID: 165)
2>  --- (Aufgaben-ID: 165)
2>    at MonoTouch.Tuner.Linker.Process (MonoTouch.Tuner.LinkerOptions options, MonoTouch.Tuner.MonoTouchLinkContext& context, System.Collections.Generic.List`1[Mono.Cecil.AssemblyDefinition]& assemblies) [0x003ad] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/mtouch/Tuning.cs:124  (Aufgaben-ID: 165)
2>    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) [0x0029a] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/mtouch/Target.cs:491  (Aufgaben-ID: 165)
2>    at Xamarin.Bundler.Target.ManagedLink () [0x005c5] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/mtouch/Target.cs:614  (Aufgaben-ID: 165)
2>    at Xamarin.Bundler.Target.ProcessAssemblies () [0x000bb] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/mtouch/Target.cs:800  (Aufgaben-ID: 165)
2>    at Xamarin.Bundler.Application.ProcessAssemblies () [0x0002f] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/mtouch/Application.cs:1407  (Aufgaben-ID: 165)
2>    at Xamarin.Bundler.Application.BuildManaged () [0x00001] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/mtouch/Application.cs:831  (Aufgaben-ID: 165)
2>    at Xamarin.Bundler.Application+<>c.<BuildAll>b__134_1 (Xamarin.Bundler.Application v) [0x00000] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/mtouch/Application.cs:779  (Aufgaben-ID: 165)
2>    at System.Collections.Generic.List`1[T].ForEach (System.Action`1[T] action) [0x00024] in <ac812cae460544af83bd6cf54c5eee87>:0  (Aufgaben-ID: 165)
2>    at Xamarin.Bundler.Application.BuildAll () [0x00050] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/mtouch/Application.cs:779  (Aufgaben-ID: 165)
2>    at Xamarin.Bundler.Driver.Main2 (System.String[] args) [0x00481] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/mtouch/mtouch.cs:1401  (Aufgaben-ID: 165)
2>    at Xamarin.Bundler.Driver.Main (System.String[] args) [0x0000f] in /Users/builder/data/lanes/5481/2f8bbec0/source/xamarin-macios/tools/mtouch/mtouch.cs:926  (Aufgaben-ID: 165)
2>  Tool /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mtouch execution finished. (Aufgaben-ID: 165)
Comment 1 Alex Soto [MSFT] 2017-10-13 16:10:15 UTC
Hello this is a duplicate of bug #60163 please keep an eye on it.

*** This bug has been marked as a duplicate of bug 60163 ***
Comment 2 Rolf Bjarne Kvinge [MSFT] 2017-10-16 10:45:41 UTC
It looks like bug #60163 is not a duplicate, it's a different issue (which looks quite similar).
Comment 3 Rolf Bjarne Kvinge [MSFT] 2017-10-16 10:46:01 UTC
Could you please attach a test project we can use to reproduce this?
Comment 4 panico 2017-10-19 10:47:42 UTC
I am afraid not, because I do not have access to my dev envirnoment for the next six weeks. But in the meantime I managed to digg deeper and found that we have a LinkDescription.xml in the project. The following line lead to the problem:

    <type fullname="System.Reflection.*"/>

this was the original xml file:

<linker>
  <assembly fullname="mscorlib">
    <type fullname="System.Reflection.AssemblyInformationalVersionAttribute"/>
    <type fullname="System.Reflection.AssemblyDefaultAliasAttribute"/>
    <type fullname="System.Runtime.InteropServices.ComVisibleAttribute"/>
    <type fullname="System.Security.AllowPartiallyTrustedCallersAttribute"/>
    <type fullname="System.Security.SecurityCriticalAttribute"/>
    <type fullname="System.Reflection.AssemblyKeyFileAttribute"/>
    <type fullname="System.Reflection.AssemblyDelaySignAttribute"/>
    <type fullname="System.Reflection.*"/>
    <type fullname="System.Resources.*"/>
  </assembly>
  <assembly fullname="Microsoft.Practices.Unity">
    <type fullname="Microsoft.Practices.*"/>
  </assembly>
  <assembly fullname="AutoMapper">
    <namespace fullname="AutoMapper" />
    <type fullname="AutoMapper.*" />
    <namespace fullname="AutoMapper.Mappers" />
    <type fullname="AutoMapper.Mappers.*" />
  </assembly>
  <assembly fullname="AutoMapper.Collection">
    <type fullname="AutoMapper.Mappers.ObjectToEquivalencyExpressionByEquivalencyExistingMapper"/>
    <type fullname="AutoMapper.Mappers.EquivalentExpressionAddRemoveCollectionMapper"/>
    <type fullname="AutoMapper.ConfigurationValidator.*"/>
  </assembly>
  <assembly fullname="System.Collections">
    <namespace fullname="System.Collections.Generic" />
    <type fullname="System.Collections.Generic.*" />
  </assembly>
</linker>


I then finally managed to workaround the issue by not using the wildcard calls, but specifying the missing types by full name. Still strange, that type INCLUSION leads to null reference. Does this help?
Comment 5 panico 2017-10-19 10:48:24 UTC
I am afraid not, because I do not have access to my dev envirnoment for the next six weeks. But in the meantime I managed to digg deeper and found that we have a LinkDescription.xml in the project. The following line lead to the problem:

    <type fullname="System.Reflection.*"/>

this was the original xml file:

<linker>
  <assembly fullname="mscorlib">
    <type fullname="System.Reflection.AssemblyInformationalVersionAttribute"/>
    <type fullname="System.Reflection.AssemblyDefaultAliasAttribute"/>
    <type fullname="System.Runtime.InteropServices.ComVisibleAttribute"/>
    <type fullname="System.Security.AllowPartiallyTrustedCallersAttribute"/>
    <type fullname="System.Security.SecurityCriticalAttribute"/>
    <type fullname="System.Reflection.AssemblyKeyFileAttribute"/>
    <type fullname="System.Reflection.AssemblyDelaySignAttribute"/>
    <type fullname="System.Reflection.*"/>
    <type fullname="System.Resources.*"/>
  </assembly>
  <assembly fullname="Microsoft.Practices.Unity">
    <type fullname="Microsoft.Practices.*"/>
  </assembly>
  <assembly fullname="AutoMapper">
    <namespace fullname="AutoMapper" />
    <type fullname="AutoMapper.*" />
    <namespace fullname="AutoMapper.Mappers" />
    <type fullname="AutoMapper.Mappers.*" />
  </assembly>
  <assembly fullname="AutoMapper.Collection">
    <type fullname="AutoMapper.Mappers.ObjectToEquivalencyExpressionByEquivalencyExistingMapper"/>
    <type fullname="AutoMapper.Mappers.EquivalentExpressionAddRemoveCollectionMapper"/>
    <type fullname="AutoMapper.ConfigurationValidator.*"/>
  </assembly>
  <assembly fullname="System.Collections">
    <namespace fullname="System.Collections.Generic" />
    <type fullname="System.Collections.Generic.*" />
  </assembly>
</linker>


I then finally managed to workaround the issue by not using the wildcard calls, but specifying the missing types by full name. Still strange, that type INCLUSION leads to null reference. Does this help?
Comment 6 Rolf Bjarne Kvinge [MSFT] 2017-10-23 12:17:47 UTC
Thanks, that xml definition was crucial in figuring this out.

Fix in progress: https://github.com/xamarin/xamarin-macios/pull/2915