We're creating a Unified Xamarin Forms application using Forms 1.3.1.6294-pre1. Currently we have a blocking issue when trying to run an application on a iPhone. The application crashes during startup (loading the XAML) with an exception:
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00016] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:543
at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x000af] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:329
at System.Activator.CreateInstance (System.Type type) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:222
at Xamarin.Forms.Xaml.CreateValuesVisitor.Visit (Xamarin.Forms.Xaml.ElementNode node, INode parentNode) [0x00000] in :0
[0:] at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00016] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:543
at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x000af] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:329
at System.Activator.CreateInstance (System.Type type) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:222
at Xamarin.Forms.Xaml.CreateValuesVisitor.Visit (Xamarin.Forms.Xaml.ElementNode node, INode parentNode) [0x00000] in :0
[0:]
The innerexception contains a bit more info:
2015-01-09 20:47:38.788 ..... [168:3576] Attempting to JIT compile method 'Xamarin.Forms.OnPlatform
1<int>:.ctor ()' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.
[0:] Attempting to JIT compile method 'Xamarin.Forms.OnPlatform
1:.ctor ()' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.Loaded assembly: /private/var/mobile/Containers/Bundle/Application/6D767881-02FF-4660-AAED-5BFF2E0C4260/IGDIAppiOS.app/.monotouch-64/System.Reflection.Extensions.dll
The application runs fine in the simulator. We're using XAML based views with some OnPlatform statements in it. For example:
<OnPlatform x:Key="Priority1" x:TypeArguments="x:Int32">
<OnPlatform.iOS>0</OnPlatform.iOS>
<OnPlatform.Android>1</OnPlatform.Android>
<OnPlatform.WinPhone>1</OnPlatform.WinPhone>
</OnPlatform>
I've noticed a similar report in http://forums.xamarin.com/discussion/comment/70473 where @CraigDunn responded. However, no real cause or solution was found. And there is a slight difference in the exception info. The exception here is pointing to a generic constructor.
Any ideas how to prevent this exception? Are we running into a bug of Xamarin.Forms?