Bug 23280 - RelativeLayout causing System.Reflection.TargetInvocationException when launched on iOS device (v7.1)
Summary: RelativeLayout causing System.Reflection.TargetInvocationException when launc...
Status: RESOLVED INVALID
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 1.2.1
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-09-23 04:41 UTC by Jon Goldberger [MSFT]
Modified: 2014-10-20 22:23 UTC (History)
5 users (show)

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


Attachments
Test Project (3.33 MB, application/zip)
2014-09-23 04:41 UTC, Jon Goldberger [MSFT]
Details
New project, replicated source code. (2.96 MB, application/zip)
2014-09-23 04:44 UTC, Jon Goldberger [MSFT]
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:
RESOLVED INVALID

Description Jon Goldberger [MSFT] 2014-09-23 04:41:40 UTC
Created attachment 8149 [details]
Test Project

This was tested using Xamarin Forms 1.2.1 and 1.2.2

## Steps to reproduce:

1. Open the attached test project
2. Set the iOS project as startup
3. Launch to an iOS device (Tested on device running iOS 7.1)

##Expected Result:

A screen with three buttons should display

## Actual Result

Exception is thrown with the stack trace at the end of the bug description.


Notes: 

1. Removing or commenting out the RelativeLayout from the SignUpLoginPage.xaml file avoids this exception. I tested this with the 1.2.1 version that was being used when I got the test project, but also tested after updating to 1.2.2 and got the same results.

2. Creating a new forms project in either Xamarin Studio or Visual Studio and copying the source code from the test project did not reproduce the error.

3. I looked for differences between the new solution and the original test project. All source files were identical. I tried 
>   a. Removing and reading the Xamarin Forms packages
>   b. Removing the unused components/packages in the iOS project
>   c. Adding an Entitilements.plist file to the iOS project (just trying to match everything.

None of the above did anything to resolve the issue. 

## Summary
I can not reproduce this error except in the test project sent to me by our client, but I can't find what in that project is different from a new project that is causing the error. 

>System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ExecutionEngineException: Attempting to JIT compile method 'Microsoft.Scripting.Interpreter.LightLambda:MakeRun0<Xamarin.Forms.Rectangle> (Microsoft.Scripting.Interpreter.LightLambda)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.
 
>  at Microsoft.Scripting.Interpreter.LightLambda.MakeDelegate (System.Type delegateType) [0x0000d] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.0.0.62/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightLambda.cs:177
>  at Microsoft.Scripting.Interpreter.LightDelegateCreator.CreateDelegate (System.Runtime.CompilerServices.StrongBox`1[] closure) [0x00000] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.0.0.62/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightDelegateCreator.cs:109
>  at Microsoft.Scripting.Interpreter.LightDelegateCreator.CreateDelegate () [0x00000] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.0.0.62/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightDelegateCreator.cs:81
>  at Microsoft.Scripting.Generation.CompilerHelpers.LightCompile (System.Linq.Expressions.LambdaExpression lambda) [0x00000] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.0.0.62/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Generation/CompilerHelpers.cs:619
>  at System.Linq.Expressions.Compiler.LambdaCompiler.Compile (System.Linq.Expressions.LambdaExpression lambda, System.Runtime.CompilerServices.DebugInfoGenerator debugInfoGenerator) [0x00000] in <filename unknown>:0
>  at System.Linq.Expressions.Expression`1[System.Func`1[Xamarin.Forms.Rectangle]].Compile () [0x00000] in <filename unknown>:0
>  at Xamarin.Forms.BoundsConstraint.FromExpression (System.Linq.Expressions.Expression`1 expression, IEnumerable`1 parents) [0x00000] in <filename unknown>:0
>  at Xamarin.Forms.RelativeLayout.CreateBoundsFromConstraints (Xamarin.Forms.View view, Xamarin.Forms.Constraint xConstraint, Xamarin.Forms.Constraint yConstraint, Xamarin.Forms.Constraint widthConstraint, Xamarin.Forms.Constraint heightConstraint) [0x00000] in <filename unknown>:0
>  at Xamarin.Forms.RelativeLayout.OnAdded (Xamarin.Forms.View view) [0x00000] in <filename unknown>:0
>  at Xamarin.Forms.Layout`1[Xamarin.Forms.View].ChildrenOnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0
>  at (wrapper delegate-invoke) <Module>:invoke_void_object_NotifyCollectionChangedEventArgs (object,System.Collections.Specialized.NotifyCollectionChangedEventArgs)
>  at (wrapper delegate-invoke) <Module>:invoke_void_object_NotifyCollectionChangedEventArgs (object,System.Collections.Specialized.NotifyCollectionChangedEventArgs)
>  at System.Collections.ObjectModel.ObservableCollection`1[Xamarin.Forms.Element].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0
>  at System.Collections.ObjectModel.ObservableCollection`1[Xamarin.Forms.Element].InsertItem (Int32 index, Xamarin.Forms.Element item) [0x00000] in <filename unknown>:0
>  at System.Collections.ObjectModel.Collection`1[Xamarin.Forms.Element].Add (Xamarin.Forms.Element item) [0x00000] in <filename unknown>:0
>  at Xamarin.Forms.ObservableWrapper`2[Xamarin.Forms.Element,Xamarin.Forms.View].Add (Xamarin.Forms.View item) [0x00000] in <filename unknown>:0
>  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
>  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00044] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:230
>  --- End of inner exception stack trace ---
>  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0005c] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:238
>  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MethodBase.cs:114
>  at Xamarin.Forms.Xaml.BaseValueNode.SetPropertyValue (System.Object xamlelement, XmlName propertyName, System.Object value, Xamarin.Forms.BindableObject rootElement) [0x00000] in <filename unknown>:0
>  at Xamarin.Forms.Xaml.ElementNode.ApplyTo (System.Object source, XmlName propertyName, Boolean dontUseLazy) [0x00000] in <filename unknown>:0
>  at Xamarin.Forms.Xaml.INodeExtension.ApplyProperties (IElementNode node, System.Object source, Boolean dontUseLazy) [0x00000] in <filename unknown>:0
>  at Xamarin.Forms.Xaml.ElementNode.ApplyProperties (System.Object source, Boolean dontUseLazy) [0x00000] in <filename unknown>:0
>  at Xamarin.Forms.Xaml.ElementNode.Create (Boolean dontUseLazy) [0x00000] in <filename unknown>:0
>  at Xamarin.Forms.Xaml.ElementNode.<.ctor>b__0 () [0x00000] in <filename unknown>:0
>  at System.Lazy`1[System.Object].InitValue () [0x00000] in <filename unknown>:0
Comment 2 Jon Goldberger [MSFT] 2014-09-23 04:44:29 UTC
Created attachment 8150 [details]
New project, replicated source code.

The issue does not occur in this new project with the source code copied from the original test project
Comment 3 Parmendra Kumar 2014-09-24 06:31:51 UTC
I have checked this issue with the steps mentioned in the bug description, And I am getting the same exception when deploy to device iOS7.1 and iOS 8.0. Its working fine with simulator.

Screencast:http://screencast.com/t/Xtx92iAiQT
IDE Log:https://gist.github.com/anonymous/ac13083c6a644dc7fb89
Application OutputLog: https://gist.github.com/anonymous/015f509c9877b7fb93ba

Environment Info:

=== Xamarin Studio ===

Version 5.4 (build 240)
Installation UUID: 1a096c6f-0678-402e-89b2-a2c10f7e80e4
Runtime:
	Mono 3.8.0 ((no/45d0ba1)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 308000009

=== Apple Developer Tools ===

Xcode 6.0.1 (6528)
Build 6A317

=== Xamarin.Mac ===

Version: 1.10.0.13 (Business Edition)

=== Xamarin.Android ===

Version: 4.16.0 (Business Edition)

=== Xamarin.iOS ===

Version: 8.0.0.62 (Business Edition)
Hash: 8bd8158
Branch: 
Build date: 2014-09-18 09:12:55-0400
Comment 4 jjsan 2014-09-30 09:12:46 UTC
i have the same problem

Relative relative = new Relative ();
StackLayout stack = new StackLayout {
Children = 
{
view, 
grid
}
};
relative.Children.Add(stack, () => relative.Bounds);

if I change Relative for StackLayout its ok. (not by design but without exception)

System.ExecutionEngineException: Attempting to JIT compile method 'Microsoft.Scripting.Interpreter.LightLambda:MakeRun0<Xamarin.Forms.Rectangle> (Microsoft.Scripting.Interpreter.LightLambda)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.

  at Microsoft.Scripting.Interpreter.LightLambda.MakeDelegate (System.Type delegateType) [0x0000d] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.0.0.63/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightLambda.cs:177
  at Microsoft.Scripting.Interpreter.LightDelegateCreator.CreateDelegate (System.Runtime.CompilerServices.StrongBox`1[] closure) [0x00000] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.0.0.63/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightDelegateCreator.cs:109
  at Microsoft.Scripting.Interpreter.LightDelegateCreator.CreateDelegate () [0x00000] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.0.0.63/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Interpreter/LightDelegateCreator.cs:81
  at Microsoft.Scripting.Generation.CompilerHelpers.LightCompile (System.Linq.Expressions.LambdaExpression lambda) [0x00000] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.0.0.63/src/mono/mcs/class/dlr/Runtime/Microsoft.Dynamic/Generation/CompilerHelpers.cs:619
  at System.Linq.Expressions.Compiler.LambdaCompiler.Compile (System.Linq.Expressions.LambdaExpression lambda, System.Runtime.CompilerServices.DebugInfoGenerator debugInfoGenerator) [0x00000] in <filename unknown>:0
  at System.Linq.Expressions.Expression`1[System.Func`1[Xamarin.Forms.Rectangle]].Compile () [0x00000] in <filename unknown>:0
  at Xamarin.Forms.BoundsConstraint.FromExpression (System.Linq.Expressions.Expression`1 expression, IEnumerable`1 parents) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.RelativeLayout+RelativeElementCollection.Add (Xamarin.Forms.View view, System.Linq.Expressions.Expression`1 bounds) [0x00000] in <filename unknown>:0
  at WebSigner.Screen.HomeScreen..ctor () [0x0032d] in /Users/disigas/Desktop/WebSigner/WebSigner/WebSigner/Screen/HomeScreen.cs:131
  at WebSigner.App.GetMainPage () [0x00032] in /Users/disigas/Desktop/WebSigner/WebSigner/WebSigner/App.cs:19
  at WebSigner.iOS.AppDelegate.FinishedLaunching (MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary options) [0x00021] in /Users/disigas/Desktop/WebSigner/WebSigner/WebSigner.iOS/AppDelegate.cs:34
  at at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:62
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0001c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:45
  at WebSigner.iOS.Application.Main (System.String[] args) [0x00008] in /Users/disigas/Desktop/WebSigner/WebSigner/WebSigner.iOS/Main.cs:17
Comment 5 Jason Smith [MSFT] 2014-10-20 22:23:27 UTC
You cannot specify expressions that require JITing to have it actually work on iOS. This means there are some limitations, you also need to make sure you have the latest version of Xamarin.iOS