Bug 59184 - MethodInfo.Invoke fails for generic methods with too many/too large arguments
Summary: MethodInfo.Invoke fails for generic methods with too many/too large arguments
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Mono runtime / AOT compiler (show other bugs)
Version: XI 10.12 (d15-3)
Hardware: PC Windows
: Normal normal
Target Milestone: 15.7
Assignee: Manuel de la Peña [MSFT]
URL:
: 58424 61020 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-09-01 18:40 UTC by Rob Kite
Modified: 2018-02-23 22:36 UTC (History)
18 users (show)

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


Attachments
Additional testing details for Comment 48 (3.01 KB, text/plain)
2018-02-06 05:46 UTC, Brendan Zagaeski (Xamarin Team, assistant)
Details

Description Rob Kite 2017-09-01 18:40:19 UTC
This one had me puzzled for most of the day. It would appear that inclusion of an enum in an Entity Framework Core data model can cause Xamarin.iOS to throw a JIT error / limitation message.

Annoyingly the issue isn't present in the simulator, and in my case at least also isn't present if the majority of other properties are removed (leaving the navigation properties and enum properties only). Have also tried setting Linker Behaviour to 'Don't Link' but this doesn't change the exception. I do have mtouch arguments set to '--linkskip=System.Core --linkskip=mscorlib' which has removed any issues with general Linq queries used in EFCore (a completely separate issue).


### Repro project
EFCore.Data - The EFCore implementation
EFCore.App - The iOS Application (which throws and exception when clicking 'Add Quotation' on a physical device)
EFCore.Console - A .NET Console App showing that the EFCore implementation is valid and works

Github link:
https://github.com/robkite/EFCore.App


### Repro steps
TO resolve the issue simply comment out the enum properties in the Quotation and User domain classes (PropertyType and Relation respectively) within the EFCore.Data project. However removing the majority of properties besides the enums and the navigation properties also seems to resolve the issue.

### Machine Environment
Microsoft Visual Studio Community 2017 
Version 15.3.0
VisualStudio.15.Release/15.3.0+26730.3
Microsoft .NET Framework
Version 4.7.02053

Installed Version: Community

Visual Basic 2017
Microsoft Visual Basic 2017

Visual C# 2017
Microsoft Visual C# 2017

Visual C++ 2017
Microsoft Visual C++ 2017

Visual F# 4.1 
Microsoft Visual F# 4.1

Application Insights Tools for Visual Studio Package   8.8.00712.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017   15.0.30726.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services   1.0
Provides languages services for ASP.NET Core Razor.

ASP.NET Template Engine 2017   15.0.30726.0
ASP.NET Template Engine 2017

ASP.NET Web Frameworks and Tools 2017   5.2.50601.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   15.0.30728.0
Azure App Service Tools v3.0.0

Azure Data Lake Node   1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio   2.2.9000.1
Microsoft Azure Data Lake Tools for Visual Studio

Azure Data Lake Tools for Visual Studio   2.2.9000.1
Microsoft Azure Data Lake Tools for Visual Studio

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

GhostDoc   5.6.17190.0
Generate XML Comments from your code, maintain clean and up-to-date documentation, produce help documentation in multiple formats, use intelligent source code Spell Checker in Visual Studio.

JavaScript Language Service   2.0
JavaScript Language Service

Merq   1.1.17-rc (cba4571)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft Azure HDInsight Azure Node   2.2.9000.1
HDInsight Node under Azure Node

Microsoft Azure Hive Query Language Service   2.2.9000.1
Language service for Hive query

Microsoft Azure Stream Analytics Language Service   2.2.9000.1
Language service for Azure Stream Analytics

Microsoft Azure Stream Analytics Node   1.0
Azure Stream Analytics Node under Azure Node

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.50719.1

Microsoft Continuous Delivery Tools for Visual Studio   0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards   1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio   4.6.8-pre (ec7034f)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   4.3.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

SQL Server Data Tools   15.1.61707.200
Microsoft SQL Server Data Tools

ToolWindowHostedEditor   1.0
Hosting json editor into a tool window

TypeScript   2.3.4.0
TypeScript tools for Visual Studio

Visual C++ for Cross Platform Mobile Development (Android)   15.0.26724.01
Visual C++ for Cross Platform Mobile Development (Android)

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio tools for CMake   1.0
Visual Studio tools for CMake

Xamarin   4.6.0.295 (306f76a)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK   7.4.0.19 (0cd0214)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK   10.12.0.14 (bf350ba)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.



### Exception Log
EFCore.App[509:147301] System.ExecutionEngineException: Attempting to JIT compile method '(wrapper runtime-invoke) <Module>:runtime_invoke_void__this___int_int_object_object_object_object_byte_int_int_double_double_double_object_double (object,intptr,intptr,intptr)' while running in aot-only mode. See https://developer.xamarin.com/guides/ios/advanced_topics/limitations/ for more information.

  at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_thread_interruption_checkpoint ()
  at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
  at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.20/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:661 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.Excepti
onDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.20/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151 
  at System.Linq.Expressions.Interpreter.ExceptionHelpers.UnwrapAndRethrow (System.Reflection.TargetInvocationException exception) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.20/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/Utilities.cs:174 
  at System.Linq.Expressions.Interpreter.NewInstruction.Run (System.Linq.Expressions.Interpreter.InterpretedFrame frame) [0x00026] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.20/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/NewInstruction.cs:39 
  at System.Linq.Expressions.Interpreter.Interpreter.Run (System.Linq.Expressions.Interpreter.InterpretedFrame frame) [0x00015] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.
0.20/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/Interpreter.cs:63 
  at System.Linq.Expressions.Interpreter.LightLambda.Run1[T0,TRet] (T0 arg0) [0x0001c] in <3d531496fdc44f9da4b499fb8ef64a66>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry+OriginalValues..ctor (Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry entry) [0x0000c] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.EnsureOriginalValues () [0x0000d] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntrySubscriber.SnapshotAndSubscribe (Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry entry) [0x0000f] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.StartTracking (Microsoft.EntityFrameworkCore.ChangeTracking.Internal.Internal
EntityEntry entry) [0x00094] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetEntityState (Microsoft.EntityFrameworkCore.EntityState oldState, Microsoft.EntityFrameworkCore.EntityState newState, System.Boolean acceptChanges) [0x00141] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetEntityState (Microsoft.EntityFrameworkCore.EntityState entityState, System.Boolean acceptChanges) [0x00026] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.PaintAction (Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntryGraphNode node) [0x00034] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityEntryGraphIterator.TraverseGraph (Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntryGraphNode node, System.Func`2[T,TResult] handleNode) [0x00000] in <2645c1
c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityEntryGraphIterator.TraverseGraph (Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntryGraphNode node, System.Func`2[T,TResult] handleNode) [0x0007a] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.AttachGraph (Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry rootEntry, Microsoft.EntityFrameworkCore.EntityState entityState) [0x00019] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.DbContext.SetEntityState (Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry entry, Microsoft.EntityFrameworkCore.EntityState entityState) [0x00025] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.DbContext.SetEntityState[TEntity] (TEntity entity, Microsoft.EntityFrameworkCore.EntityState entityState) [0x0000f] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Micros
oft.EntityFrameworkCore.DbContext.Add[TEntity] (TEntity entity) [0x0000c] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1[TEntity].Add (TEntity entity) [0x00000] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at EFCore.App.ViewController.AddQuotationBtn_TouchUpInside (UIKit.UIButton sender) [0x00044] in d:\Users\robert kite\documents\visual studio 2017\Projects\EFCore.App\EFCore.App\ViewController.cs:33 
2017-09-01 19:23:55.189 EFCore.App[509:147301] Attempting to JIT compile method '(wrapper runtime-invoke) <Module>:runtime_invoke_void__this___int_int_object_object_object_object_byte_int_int_double_double_double_object_double (object,intptr,intptr,intptr)' while running in aot-only mode. See https://developer.xamarin.com/guides/ios/advanced_topics/limitations/ for more information.
Unhandled Exception:

System.ExecutionEngineException: Attempting to JIT compile method '(wrapper runtime-invoke) <Module>:runtime_invoke_void__this___int_int_object_object_object_object_byte_int_int_double_double_double_object_double (object,intptr,intptr,intptr)' while running in aot-only mode. See https://developer.xamarin.com/guides/ios/advanced_topics/limitations/ for more information.


2017-09-01 19:24:03.679 EFCore.App[509:147301] 
Unhandled Exception:
System.ExecutionEngineException: Attempting to JIT compile method '(wrapper runtime-invoke) <Module>:runtime_invoke_void__this___int_int_object_object_object_object_byte_int_int_double_double_double_object_double (object,intptr,intptr,intptr)' while running in aot-only mode. See https://developer.xamarin.com/guides/ios/advanced_topics/limitations/ for more information.

  at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_thread_interruption_checkpoint ()
  at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
  at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.20/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:661 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.Exc
eptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.20/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151 
  at System.Linq.Expressions.Interpreter.ExceptionHelpers.UnwrapAndRethrow (System.Reflection.TargetInvocationException exception) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.20/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/Utilities.cs:174 
  at System.Linq.Expressions.Interpreter.NewInstruction.Run (System.Linq.Expressions.Interpreter.InterpretedFrame frame) [0x00026] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.20/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/NewInstruction.cs:39 
  at System.Linq.Expressions.Interpreter.Interpreter.Run (System.Linq.Expressions.Interpreter.InterpretedFrame frame) [0x00015] in /Library/Frameworks/Xamarin.iOS.fra
mework/Versions/10.12.0.20/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/Interpreter.cs:63 
  at System.Linq.Expressions.Interpreter.LightLambda.Run1[T0,TRet] (T0 arg0) [0x0001c] in <3d531496fdc44f9da4b499fb8ef64a66>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry+OriginalValues..ctor (Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry entry) [0x0000c] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.EnsureOriginalValues () [0x0000d] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntrySubscriber.SnapshotAndSubscribe (Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry entry) [0x0000f] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.StartTracking (Microsoft.EntityFrameworkCore.ChangeTrac
king.Internal.InternalEntityEntry entry) [0x00094] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetEntityState (Microsoft.EntityFrameworkCore.EntityState oldState, Microsoft.EntityFrameworkCore.EntityState newState, System.Boolean acceptChanges) [0x00141] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetEntityState (Microsoft.EntityFrameworkCore.EntityState entityState, System.Boolean acceptChanges) [0x00026] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.PaintAction (Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntryGraphNode node) [0x00034] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityEntryGraphIterator.TraverseGraph (Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntryGraphNode node, System.Func`2[T,TResult] handleNode
) [0x00000] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityEntryGraphIterator.TraverseGraph (Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntryGraphNode node, System.Func`2[T,TResult] handleNode) [0x0007a] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.AttachGraph (Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry rootEntry, Microsoft.EntityFrameworkCore.EntityState entityState) [0x00019] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.DbContext.SetEntityState (Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry entry, Microsoft.EntityFrameworkCore.EntityState entityState) [0x00025] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.DbContext.SetEntityState[TEntity] (TEntity entity, Microsoft.EntityFrameworkCore.EntityState entityState) [0x0000f] in <2645c1c7345546f5b968e91de8
1e2b12>:0 
  at Microsoft.EntityFrameworkCore.DbContext.Add[TEntity] (TEntity entity) [0x0000c] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1[TEntity].Add (TEntity entity) [0x00000] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at EFCore.App.ViewController.AddQuotationBtn_TouchUpInside (UIKit.UIButton sender) [0x00086] in d:\Users\robert kite\documents\visual studio 2017\Projects\EFCore.App\EFCore.App\ViewController.cs:41 
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/4991/80b8487d/source/xamarin-macios/src/UIKit/UIApplication.cs:79 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/4991/80b8487d/source/xamarin-macios/src/UIKit/UIApplication.cs:63 
  at EFCore
.App.Application.Main (System.String[] args) [0x00001] in d:\Users\robert kite\documents\visual studio 2017\Projects\EFCore.App\EFCore.App\Main.cs:9 
2017-09-01 19:24:03.693 EFCore.App[509:147301] Unhandled managed exception:
Attempting to JIT compile method '(wrapper runtime-invoke) <Module>:runtime_invoke_void__this___int_int_object_object_object_object_byte_int_int_double_double_double_object_double (object,intptr,intptr,intptr)' while running in aot-only mode. See https://developer.xamarin.com/guides/ios/advanced_topics/limitations/ for more information.
 (System.ExecutionEngineException)
  at (wrapper managed-to-native) System.Object:__icall_wrapper_mono_thread_interruption_checkpoint ()
  at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
  at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.20/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:661 
--- End of stack trace from previous location where exception was thrown ---
  at System.Run
time.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.20/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151 
  at System.Linq.Expressions.Interpreter.ExceptionHelpers.UnwrapAndRethrow (System.Reflection.TargetInvocationException exception) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.20/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/Utilities.cs:174 
  at System.Linq.Expressions.Interpreter.NewInstruction.Run (System.Linq.Expressions.Interpreter.InterpretedFrame frame) [0x00026] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.20/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/NewInstruction.cs:39 
  at System.Linq.Expressions.Interpreter.Interpreter.Run (System.Linq.Expressions.Interpreter.InterpretedFrame frame) [0x00015] in /Library/Frameworks/Xamarin
.iOS.framework/Versions/10.12.0.20/src/mono/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/Interpreter.cs:63 
  at System.Linq.Expressions.Interpreter.LightLambda.Run1[T0,TRet] (T0 arg0) [0x0001c] in <3d531496fdc44f9da4b499fb8ef64a66>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry+OriginalValues..ctor (Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry entry) [0x0000c] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.EnsureOriginalValues () [0x0000d] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntrySubscriber.SnapshotAndSubscribe (Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry entry) [0x0000f] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.StartTracking (Microsoft.EntityFrameworkCore.Ch
angeTracking.Internal.InternalEntityEntry entry) [0x00094] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetEntityState (Microsoft.EntityFrameworkCore.EntityState oldState, Microsoft.EntityFrameworkCore.EntityState newState, System.Boolean acceptChanges) [0x00141] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetEntityState (Microsoft.EntityFrameworkCore.EntityState entityState, System.Boolean acceptChanges) [0x00026] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.PaintAction (Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntryGraphNode node) [0x00034] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityEntryGraphIterator.TraverseGraph (Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntryGraphNode node, System.Func`2[T,TResult] ha
ndleNode) [0x00000] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityEntryGraphIterator.TraverseGraph (Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntryGraphNode node, System.Func`2[T,TResult] handleNode) [0x0007a] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.AttachGraph (Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry rootEntry, Microsoft.EntityFrameworkCore.EntityState entityState) [0x00019] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.DbContext.SetEntityState (Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry entry, Microsoft.EntityFrameworkCore.EntityState entityState) [0x00025] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.DbContext.SetEntityState[TEntity] (TEntity entity, Microsoft.EntityFrameworkCore.EntityState entityState) [0x0000f] in <2645c1c7345546f5b9
68e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.DbContext.Add[TEntity] (TEntity entity) [0x0000c] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1[TEntity].Add (TEntity entity) [0x00000] in <2645c1c7345546f5b968e91de81e2b12>:0 
  at EFCore.App.ViewController.AddQuotationBtn_TouchUpInside (UIKit.UIButton sender) [0x00086] in d:\Users\robert kite\documents\visual studio 2017\Projects\EFCore.App\EFCore.App\ViewController.cs:41 
  at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/4991/80b8487d/source/xamarin-macios/src/UIKit/UIApplication.cs:79 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/4991/80b8487d/source/xamarin-macios/src/UIKit/UIApplication.cs:63 
  a
t EFCore.App.Application.Main (System.String[] args) [0x00001] in d:\Users\robert kite\documents\visual studio 2017\Projects\EFCore.App\EFCore.App\Main.cs:9 
2017-09-01 19:24:03.694 EFCore.App[509:147301] critical: Stacktrace:
Comment 1 Vincent Dondain [MSFT] 2017-09-04 03:03:33 UTC
Hi,

I could successfully reproduce this issue using the GitHub project linked in the description, on device, with XI 10.12.3.3 (d15-3) and 10.10.0.36 (d15-2).

Here's the full build output I got: https://gist.github.com/VincentDondain/12c2fc63fe2a2849cb3d56499fd17f76

As well as my versions information: https://gist.github.com/VincentDondain/9f2c2188e0b266ecce4ace38e6ea94a1
Comment 2 Zoltan Varga 2017-09-04 03:31:35 UTC
A minimal testcase:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                public class AClass<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17> {
                        public static void doit (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9, T10 t10, T11 t11, T12 t12, T13 t13, T14 t14, T15 t15, T16 t16, T17 t17) {
                                Console.WriteLine (t10);
                                Console.WriteLine (t17);
                        }
                }

                public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
                {
                        var t = typeof (AClass<,,,,,,,,,,,,,,,,>).MakeGenericType (new Type [] { typeof (string), typeof (string), typeof (string),

                                          typeof (string), typeof (string), typeof (string),typeof (string), typeof (string), typeof (string),typeof (string), typeof (string), typeof (string), typeof (string),

                                          typeof (string), typeof (string), typeof (string), typeof (string) });
                        object[] args = new object [17];
                        for (int i = 0; i < 17; ++i)
                                args [i] = "A" + i;
                        t.GetMethod ("doit").Invoke (null, args);
                }
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Comment 3 Rob Kite 2017-09-04 08:28:50 UTC
Is there a suitable workaround for my specific issue? Can I make some simple changes in the model?

Is the issue a direct result of the number of properties in the class, would reducing it and adding another class resolve my issue?
Comment 4 Rob Kite 2017-09-05 13:21:12 UTC
I've been able to workaround this for now by splitting up properties in my model into other classes. While this works it's not ideal as I now have additional tables in the database and additional concerns / performance impacts from joining the data between these tables.
Comment 5 Zoltan Varga 2017-09-19 20:53:19 UTC
*** Bug 59401 has been marked as a duplicate of this bug. ***
Comment 6 Zoltan Varga 2017-09-20 09:07:56 UTC
Work in progress:
https://github.com/mono/mono/pull/5612
Comment 7 Zoltan Varga 2017-09-24 08:44:46 UTC
*** Bug 58424 has been marked as a duplicate of this bug. ***
Comment 8 Zoltan Varga 2017-09-27 01:31:38 UTC
This should be fixed by:
https://github.com/mono/mono/pull/5612
but only for 64 bit arm, 32 bit arm still has the problem.
Comment 9 Rafael Romero 2017-10-18 00:43:12 UTC
Zoltan Varga How can I workaround the problem?  In a 32 bit Ipad? What would you recomend? I am know commited to entityframework in my ios app. I really need a workaround.
Comment 10 Zoltan Varga 2017-10-18 12:28:35 UTC
There is no known workaround right now for user code, the entityframework code needs to be changed.
Comment 11 Diego Vega 2017-10-18 13:04:11 UTC
FWIW, we haven’t found a reasonable change we can apply on the Entity Framework Core Core to workaround this limitation. It seems depending on the data type size, even using a threshold of 2 generic arguments can hit this. See https://github.com/aspnet/EntityFrameworkCore/issues/9249#issuecomment-332686413 for more information.
Comment 12 Zoltan Varga 2017-10-21 18:22:38 UTC
arm32 changes:

https://github.com/mono/mono/pull/5840
Comment 13 Rob Kite 2017-10-27 11:02:01 UTC
Great to see the fixes going into mono - is there any rough ETA on when Xamarin will see these fixes (or is there a preview already running on a version of mono with these fixes)?.

Currently I'm having to chop up my model into different tables and use .Include far more often than I'd like as I keep running into the issue!

Thanks

Rob
Comment 14 Zoltan Varga 2017-10-27 13:03:16 UTC
Backport to mono 2017-10:
https://github.com/mono/mono/pull/5885
Comment 15 Zoltan Varga 2017-10-27 22:41:08 UTC
The relevant changes are now on the mono 2017-10 branch.
Comment 16 Rob Kite 2017-11-01 11:19:23 UTC
Nice work - thanks!
Comment 17 Robert 2017-11-03 19:11:37 UTC
I’m running into the same issue. When will it be part of an official Xamarin release?
Comment 18 Zoltan Varga 2017-11-04 16:31:17 UTC
Can somebody answer the question from Comment 17 ?
Comment 19 Marek Safar 2017-11-04 16:49:31 UTC
The fix should be included in what we call internally dev15-6 Xamarin rollout which is the next XI version after 11.4 release
Comment 20 Timothy Risi 2017-12-07 21:12:30 UTC
*** Bug 61020 has been marked as a duplicate of this bug. ***
Comment 21 Mike Miller 2017-12-29 14:13:21 UTC
This shows as resolved, but I'm still seeing it.  I've not tried breaking apart my classes to see if I can resolve it, but the symptoms are certainly the same.
Comment 22 John Miller [MSFT] 2018-01-02 18:05:28 UTC
@Mike Miller,

Sorry for the confusion! Comment #19 indicates we can expect this to be part of the 15.6 release. That is not out yet and the current Preview does not contain any new Xamarin.iOS bits. I'll update your Developer Community post once this is included in a release that you can download.
Comment 23 Christophe C 2018-01-11 08:57:27 UTC
It seems to be fixed on d15-6 preview 2.
Comment 24 tom.denoo 2018-01-11 19:20:26 UTC
@ Christphe C

I'm quite new to xamarin. What do you mean by d15-6 preview 2?
Is this the visual studio preview: https://releases.xamarin.com/preview-release-15-6-preview-2/ ??

I'm still hitting this error with 15.6 preview 2 with xamarin.IOS 11.8.0.0 whenever my model has more than 13 properties.

I really need to deploy a new IOS release and i'm not so keen on splitting up my entities just for the IOS project.

Stacktrace

2018-01-11 19:52:41.998 PIN8610.iOS[2397:657758] ConvertToNSExceptionAndAbort
2018-01-11 19:52:42.026 PIN8610.iOS[2397:657758] Inserted Xamarin Exception Stack Line!
2018-01-11 19:52:42.026 PIN8610.iOS[2397:657758] Name: System.ExecutionEngineException
2018-01-11 19:52:42.028 PIN8610.iOS[2397:657758] MessageSystem.ExecutionEngineException: Attempting to JIT compile method '(wrapper runtime-invoke) <Module>:runtime_invoke_void__this___int_double_byte_object_object_double_Nullable`1<DateTime>_byte_object_Nullable`1<bool>_object_object_object_byte_double_object_object_object_object (object,intptr,intptr,intptr)' while running in aot-only mode. See https://developer.xamarin.com/guides/ios/advanced_topics/limitations/ for more information.Xamarin Exception Stack:

  at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke(System.Reflection.MonoCMethod,object,object[],System.Exception&)
  at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.1/src/Xamarin.iOS/mcs/class/corlib/System.Reflection/MonoMethod.cs:661 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.Exceptio
nDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.1/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152 
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Exception source) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.1/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:156 
  at System.Linq.Expressions.Interpreter.ExceptionHelpers.UnwrapAndRethrow (System.Reflection.TargetInvocationException exception) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.1/src/Xamarin.iOS/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/Utilities.cs:172 
  at System.Linq.Expressions.Interpreter.NewInstruction.Run (System.Linq.Expressions.Interpreter.InterpretedFrame frame) [0x00026] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.1/src/Xamarin.iOS
/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/NewInstruction.cs:39 
  at System.Linq.Expressions.Interpreter.Interpreter.Run (System.Linq.Expressions.Interpreter.InterpretedFrame frame) [0x00015] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.1/src/Xamarin.iOS/external/corefx/src/System.Linq.Expressions/src/System/Linq/Expressions/Interpreter/Interpreter.cs:63 
  at System.Linq.Expressions.Interpreter.LightLambda.Run1[T0,TRet] (T0 arg0) [0x0001c] in <c562c36ae1bb464a8b9bcec8fdf06d71>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry+OriginalValues..ctor (Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry entry) [0x0000c] in <f7da5a12d702478088613d8aefc8f3d1>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.EnsureOriginalValues () [0x0000d] in <f7da5a12d702478088613d8aefc8f3d1>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntrySubscriber.Sna
pshotAndSubscribe (Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry entry) [0x0000f] in <f7da5a12d702478088613d8aefc8f3d1>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.StartTracking (Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry entry) [0x0008f] in <f7da5a12d702478088613d8aefc8f3d1>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetEntityState (Microsoft.EntityFrameworkCore.EntityState oldState, Microsoft.EntityFrameworkCore.EntityState newState, System.Boolean acceptChanges) [0x00141] in <f7da5a12d702478088613d8aefc8f3d1>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry.SetEntityState (Microsoft.EntityFrameworkCore.EntityState entityState, System.Boolean acceptChanges, System.Boolean forceStateWhenUnknownKey) [0x00034] in <f7da5a12d702478088613d8aefc8f3d1>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.PaintAction (Microsoft.
EntityFrameworkCore.ChangeTracking.EntityEntryGraphNode node) [0x00024] in <f7da5a12d702478088613d8aefc8f3d1>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityEntryGraphIterator.TraverseGraph (Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntryGraphNode node, System.Func`2[T,TResult] handleNode) [0x00000] in <f7da5a12d702478088613d8aefc8f3d1>:0 
  at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.EntityGraphAttacher.AttachGraph (Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry rootEntry, Microsoft.EntityFrameworkCore.EntityState entityState, System.Boolean forceStateWhenUnknownKey) [0x00020] in <f7da5a12d702478088613d8aefc8f3d1>:0 
  at Microsoft.EntityFrameworkCore.DbContext.SetEntityState (Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntry entry, Microsoft.EntityFrameworkCore.EntityState entityState) [0x00013] in <f7da5a12d702478088613d8aefc8f3d1>:0 
  at Microsoft.EntityFrameworkCore.DbContext.SetEntityState[TEntity] (TEntity en
tity, Microsoft.EntityFrameworkCore.EntityState entityState) [0x0000f] in <f7da5a12d702478088613d8aefc8f3d1>:0 
  at Microsoft.EntityFrameworkCore.DbContext.Add[TEntity] (TEntity entity) [0x00012] in <f7da5a12d702478088613d8aefc8f3d1>:0 
  at PIN8610.AppTools.SQLiteDatabase.SaveCityList () [0x000c1] in C:\Users\Tom\Dropbox\Visual Studio\PIN8610\PIN8610\PIN8610\PIN8610.NET\AppTools\SQLiteDatabase.cs:244 
  at PIN8610.ViewModels.StartViewModel+<Go>d__33.MoveNext () [0x003bf] in C:\Users\Tom\Dropbox\Visual Studio\PIN8610\PIN8610\PIN8610\PIN8610.NET\ViewModels\StartViewModel.cs:170 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.1/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) 
[0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.1/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.1/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.1/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.1/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:113 
  at PIN8610.ViewModels.StartViewModel
+<Start>d__32.MoveNext () [0x0002d] in C:\Users\Tom\Dropbox\Visual Studio\PIN8610\PIN8610\PIN8610\PIN8610.NET\ViewModels\StartViewModel.cs:119 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.1/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.1/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1018 
  at UIKit.UIKitSynchronizationContext+<Post>c__AnonStorey0.<>m__0 () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.1/src/Xamarin.iOS/UIKit/UIKitSynchronizationContext.cs:24 
  at Foundation.NSAsyncActionDispatcher.Apply () [0x0000
0] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.1/src/Xamarin.iOS/Foundation/NSAction.cs:163 
  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.1/src/Xamarin.iOS/UIKit/UIApplication.cs:79 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.8.0.1/src/Xamarin.iOS/UIKit/UIApplication.cs:63 
  at PIN8610.iOS.Application.Main (System.String[] args) [0x00001] in C:\Users\Tom\Dropbox\Visual Studio\PIN8610\PIN8610\PIN8610\PIN8610.iOS\Main.cs:17
Comment 25 Christophe C 2018-01-11 19:33:48 UTC
I mean I tried the latest release from the beta Chanel of Visual Studio for Mac.

I found another crash with EF Core when I have only 11 properties in my entity object !
I will post the crash details tomorrow in another thread.
Comment 26 Loïc Montagne 2018-01-19 13:43:26 UTC
Hi there,

I have the same issue, because of the usage of nullables in my model.

One thing surprise me : I have tested my app compiling using Visual Studio 15.6 Preview 2.0 on 2 devices, an iPad 4 using iOs 10.3.3, and an iPad mini 2, using iOs 11.2.2. The app works fine on iOs 10.3.3 although I had this issue when I used Visual Studio 15.5.4. But on iOs 11.2.2, this issue is still there, even if I use Visual Studio 15.6 Preview 2.0.

Is there anyone who can explain to me why there is a difference between the 2 versions of iOs ?

I'm quite new Xamarin developer, and I recognize I'm a little disappointed by all the difficulties I have met during my work on this app. I REALLY NEED to deploy on the App Store my app, because I'm already very late on this project... So what can I do ? I can't restart from beginnig, it's not possible !

Thank you for your help.
Comment 27 Christophe C 2018-01-19 13:55:02 UTC
@Loïc : I think it’s not a depending of the iOS version, but of the architecture.
iPad 4 has an Apple A6x which is 32 bits and IPad mini 2 has an Apple A7 which is 64 bits.
Comment 28 Loïc Montagne 2018-01-19 14:01:08 UTC
Ok, thank you for this quick response.

This bug is mark as resolved, but for what architecture ? Is there a fix for 64 bits architecture ? And if yes, when can we have this correction on a preview ?
Comment 29 Rob Kite 2018-01-19 14:16:33 UTC
I've not tested this myself but the fix was supposed to be for 64bit initially, the 32bit fix was made slightly later.

I'm worried if the 64bit fix isn't released in VS 15.6!

64bit fix (merged 27th Sept) - https://github.com/mono/mono/pull/5612
32bit fix (merged 25th Oct) - https://github.com/mono/mono/pull/5840

Are you sure you haven't got the two muddled and it's working on 64bit and not 32bit?

The actual changes are in Mono, and should be in the 2017-10 branch. I can see that the 32bit changes were merged into this branch: https://github.com/mono/mono/pull/5885

But I'm not seeing the 64bit changes being merged in?!

Can someone at Xamarin confirm please?
Comment 30 Loïc Montagne 2018-01-19 14:43:46 UTC
Yes I'm sure : it works fine on 32bit but not on 64bit...
Comment 31 Timothy Risi 2018-01-19 20:18:14 UTC
@Loic, do you have a test project you can share that reproduces the problem?
Comment 32 Loïc Montagne 2018-01-22 10:58:46 UTC
Hi everyone,

I have made lot of tests, and here are my conclusions :
    - If you add one or more nullable property to a model class, the bug appears if this class contains 5 or more properties
    - If you you don't add nullable property, then the bug appears if the class contains 15 or more properties.
    - The bug is never appearing on 32bits devices.

Here's a link to a test project :
https://github.com/loic-montagne/AppBug59184

The test code is in this file :
AppBug59184/App.xaml.cs, in OnStart function
Comment 33 Rob Kite 2018-01-26 09:05:33 UTC
Can someone please review my previous comment #29 and confirm if the changes for the 64bit fix are missing or if they have been merged into the branch of mono? It ties in with what Loic is experiencing in the Preview.
Comment 34 Zoltan Varga 2018-01-26 17:01:42 UTC
I have problems compiling the test case on VS4Mac, it fails with:

/Library/Frameworks/Mono.framework/Versions/5.8.0/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(2057,5): warning MSB3276: Found conflicts between different versions of the same dependent assembly. Please set the "AutoGenerateBindingRedirects" property to true in the project file. For more information, see http://go.microsoft.com/fwlink/?LinkId=294190.
MTOUCH : warning MT0109: The assembly 'System.Runtime.CompilerServices.Unsafe.dll' was loaded from a different path than the provided path (provided path: /Users/vargaz/.nuget/packages/system.runtime.compilerservices.unsafe/4.4.0/lib/netstandard2.0/System.Runtime.CompilerServices.Unsafe.dll, actual path: /Users/vargaz/.nuget/packages/system.runtime.compilerservices.unsafe/4.4.0/ref/netstandard2.0/System.Runtime.CompilerServices.Unsafe.dll).
Comment 35 Zoltan Varga 2018-01-26 17:03:52 UTC
d15.6 is using the 3c3e692887af323549aca938dd6d3dca7a9a6cc8 revision of the mono 2017-10 branch which should include the fixes for both 32 and 64 bit.
Comment 37 Brendan Zagaeski (Xamarin Team, assistant) 2018-01-26 19:09:05 UTC
## Bookkeeping note

I will prepare a table of version correspondence information for this bug report (and in particular the 2 pull requests mentioned in the history of the bug report).  I should have the table ready fairly soon.
Comment 38 Brendan Zagaeski (Xamarin Team, assistant) 2018-01-26 20:13:53 UTC
My review of the commit history indicates that both of the candidate fixes that have been created so far _are_ included in the Xamarin 15.6 Preview 2 Release and higher.  The user results in Comment 24 and Comment 26 suggest that additional changes to Mono might still be needed to ensure that both of the available test cases on this bug run without error on both 32-bit and 64-bit iOS devices.

(Side note: Xamarin skipped having a "15.6 Preview 1 Release," so the Xamarin 15.6 Preview 2 Release was the first release from the "d15-6" development branches.)




## Suggested next steps for the Xamarin team

The candidate fixes have not yet been manually verified by the Xamarin team for the test case from Comment 2 using both 32-bit and 64-bit iOS devices.  That would be a good next step.

If that minimized test case works, a good next step after that would be to verify the original test case from Comment 0.




## Commit tracking notes for master and d15-6 branches, for 64-bit ARM https://github.com/mono/mono/pull/5612 (Comment 8)

> mono mono:master               commit: a54603a60449865979f6a1f7ad97b7997548c0c8 (2017-09-27)
> mono mono:2017-10              "                     "                        " (branched from mono:master _after_ the fix)
> 
> xamarin-macios xamarin:master  commit: 20182800a159a5e590d150c5b49b9016f21d074d (2017-11-14)
> xamarin-macios xamarin:d15-6   "                     "                        " (branched from xamarin:master _after_ the fix)
> 
> xamarin-android xamarin:master commit: c43c5e671aa57a56f7ba5abc3423e9906af51a83 (2017-10-31)
> xamarin-android xamarin:d15-6  "                     "                        " (branched from xamarin:master _after_ the fix)



## Commit tracking notes for d15-6 branches, for 32-bit ARM https://github.com/mono/mono/pull/5885 (Comment 14)

(This is a backport of https://github.com/mono/mono/pull/5840 (Comment 12) to the mono:2017-10 branch of mono.)

> mono mono:2017-10              commit: b471ba0bdef8b60583742628793a8868a03b299e (2017-10-27)
> 
> xamarin-macios xamarin:master  commit: 20182800a159a5e590d150c5b49b9016f21d074d (2017-11-14)
> xamarin-macios xamarin:d15-6   "                     "                        " (branched from xamarin:master _after_ the fix)
> 
> xamarin-android xamarin:master commit: c43c5e671aa57a56f7ba5abc3423e9906af51a83 (2017-10-31)
> xamarin-android xamarin:d15-6  "                     "                        " (branched from xamarin:master _after_ the fix)
Comment 39 Loïc Montagne 2018-01-26 21:21:33 UTC
Hi,

I don't really understand all Technical détails about commits, but thanks for all those précisions.

So, if I understand, VS2017 15.6 Preview 2 is not enough, but a fix must be applied to Mono too ? Is that correct ?
Comment 40 Loïc Montagne 2018-01-26 21:25:19 UTC
Other question : is Mono included in iOs ?
Comment 41 Zoltan Varga 2018-01-26 21:48:59 UTC
Can somebody try to reproduce the problem using the testcase in Comment #32 ?
Comment 42 Brendan Zagaeski (Xamarin Team, assistant) 2018-01-26 21:52:32 UTC
@Loïc, I wouldn't get too hung up on the exact details of the commits.  I think the main thing to take away from my comment from your perspective is my "Suggested next steps for the Xamarin team."  It sounds like the Xamarin team might need to investigate a little more to understand why the 2 fixes mentioned earlier in the bug report have not resolved the error in all cases (as seen in Comment 24 and Comment 26).

When I said "additional changes to Mono," I said that because the 2 fixes mentioned earlier in this bug report are originally committed into the _Mono_ repository on GitHub (https://github.com/mono/mono) , not the Xamarin.iOS repository (https://github.com/xamarin/xamarin-macios) or the Xamarin.Android repository (https://github.com/xamarin/xamarin-android) directly.  Mono is the runtime and set of base class libraries that allows compiled C# to run on Xamarin.iOS and Xamarin.Android.  To achieve this, each of those repositories includes a reference to Mono.  This can be seen in the "external" directory that contains Git submodules: https://github.com/xamarin/xamarin-macios/tree/master/external.
Comment 43 Brendan Zagaeski (Xamarin Team, assistant) 2018-01-26 21:54:52 UTC
> Can somebody try to reproduce the problem using the testcase in Comment #32 ?

Just as a quick note for clarification, I think in this case Zoltan is probably asking for somebody on the Xamarin team to try testing the problem with the test case from Comment 32 because he ran into a hiccup when trying to build that project (Comment 34).
Comment 44 Vincent Dondain [MSFT] 2018-01-29 02:54:09 UTC
@zoltan I got the same build error you got.

@Loïc does the project from https://github.com/loic-montagne/AppBug59184 compiles fine for you on VSMac from a clean build (with either our current stable or alpha)?

If neither Zoltan nor I can reproduce the issue we might need an other test case.

Version Informations: All stable

https://gist.github.com/VincentDondain/254acf58705b48e2a0938124bf210218

Build error:

/Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(2003,5): warning MSB3276: Found conflicts between different versions of the same dependent assembly. Please set the "AutoGenerateBindingRedirects" property to true in the project file. For more information, see http://go.microsoft.com/fwlink/?LinkId=294190.
MTOUCH : warning MT0109: The assembly 'System.Runtime.CompilerServices.Unsafe.dll' was loaded from a different path than the provided path (provided path: /Users/vince/.nuget/packages/system.runtime.compilerservices.unsafe/4.4.0/lib/netstandard2.0/System.Runtime.CompilerServices.Unsafe.dll, actual path: /Users/vince/.nuget/packages/system.runtime.compilerservices.unsafe/4.4.0/ref/netstandard2.0/System.Runtime.CompilerServices.Unsafe.dll).
MTOUCH : error MT3001: Could not AOT the assembly '/Users/vince/Downloads/AppBug59184-master/AppBug59184/AppBug59184.iOS/obj/iPhone/Debug/device-builds/ipad3.4-10.3.3/mtouch-cache/Build/System.Runtime.CompilerServices.Unsafe.dll'

-----

Version Informations: All alpha

https://gist.github.com/VincentDondain/777fbc7214587874b5a436d63bc32ccc

Build error:

/Library/Frameworks/Mono.framework/Versions/5.8.0/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(2057,5): warning MSB3276: Found conflicts between different versions of the same dependent assembly. Please set the "AutoGenerateBindingRedirects" property to true in the project file. For more information, see http://go.microsoft.com/fwlink/?LinkId=294190.
MTOUCH : warning MT0109: The assembly 'System.Runtime.CompilerServices.Unsafe.dll' was loaded from a different path than the provided path (provided path: /Users/vince/.nuget/packages/system.runtime.compilerservices.unsafe/4.4.0/lib/netstandard2.0/System.Runtime.CompilerServices.Unsafe.dll, actual path: /Users/vince/.nuget/packages/system.runtime.compilerservices.unsafe/4.4.0/ref/netstandard2.0/System.Runtime.CompilerServices.Unsafe.dll).
MTOUCH : error MT3001: Could not AOT the assembly '/Users/vince/Downloads/AppBug59184-master/AppBug59184/AppBug59184.iOS/obj/iPhone/Debug/device-builds/ipad3.4-10.3.3/mtouch-cache/Build/System.Runtime.CompilerServices.Unsafe.dll'
Comment 45 Loïc Montagne 2018-01-29 12:58:43 UTC
@Vincent, @Zoltan,

Hello,

I didn't test the project on VS for Mac, and I'm sorry, but I think I will not have enough time to create another test project. I'm very, very late on my app, and I have to find a solution quickly. I think I will modify all my models, but it will take a lot of time... So, sorry again...

But you can easily create your own project with the test case describe in the Comment #32. You just need to create a simple model wich match this test case (5 or 15 columns) and try to insert data into this model. You can too (if you prefer) copy models on the existing test project and paste it in a new project...
Comment 46 Mike Miller 2018-02-05 21:10:03 UTC
I have had the misfortune of needing to add another table to my application, and it seems that not all data types are created equally in terms of bumping up against this issue.

To me, it seems like Nullable, Enum, and DateTime properties affect the total number of columns you can have.  For example, I had two enums and a nullable datetime, and I was only able to have five columns total before it started blowing up.  Get rid of the enums, and that number goes up.  Get rid of the others, and the same is true.

For example, if I have a simple DateTime and get the error, I can add [NotMapped] to it and add two or three string properties in its place before it starts blowing up again.

I see that the status is currently Need Info.  Guys, seriously - this is a pretty fundamental issue and it isn't that hard to reproduce.  You just need more than 14 columns and you need to deploy it to a physical iOS device.  Use nullable types and enums and the number of columns drops dramatically.

Meet the conditions, and it blows up.  It compiles just fine, it just blows up when you try to insert rows into the table.
Comment 47 Christophe C 2018-02-05 21:46:45 UTC
I confirm what Mike Miller said. Unfortunately, we have a application in production and we need to edit our data model but we can’t because of this bug.

Please, change this bug issue to critical state.
Good luck and have fun guys ! 

You can do it :D
Comment 48 Brendan Zagaeski (Xamarin Team, assistant) 2018-02-06 05:46:14 UTC
Created attachment 26155 [details]
Additional testing details for Comment 48

One way to work around the build error from Comment 34 for the test case from Comment 33 is to copy and paste the `mtouch` command from the build output, and adjust the incorrect `ref` to `lib`.  I only had enough time to run the test case with Xamarin.iOS 11.6 on AMD64 device and confirm that it hit the problem there using that approach.  Follow-up testing will be needed with Xamarin.iOS 11.8 to check whether any scenarios still fail on that version.

My main focus for this comment was to complete my "suggested next steps for the Xamarin team" from Comment 38 since the verification of Comment 0 and Comment 2 was not yet completed.  The results from my tests demonstrate that those original scenarios were indeed fixed by the candidate changes, so any remaining occurrences of the error are exercising a different (at least slightly different) aspect of the involved code paths.




## Verification status for test case from Comment 0: verified fixed in Xamarin 15.6 Preview 3 Release

> GOOD: iPad Mini 2 (ARM64), Xamarin.iOS 11.8.0.8 (xamarin-macios branch: d15-6    commit: eaff169d)
> GOOD: iPhone 4    (ARMv7), Xamarin.iOS 11.8.0.8 "                       "                        "
> BAD:  iPad Mini 2 (ARM64), Xamarin.iOS 11.6.1.3 (xamarin-macios branch: xcode9.2 commit: f70a1348)
> BAD:  iPhone 4    (ARMv7), Xamarin.iOS 11.6.1.3 "                       "                        "



## Verification status for test case from Comment 2: verified fixed in Xamarin 15.6 Preview 3 Release

> GOOD: iPad Mini 2 (ARM64), Xamarin.iOS 11.8.0.8 (xamarin-macios branch: d15-6    commit: eaff169d)
> GOOD: iPhone 4    (ARMv7), Xamarin.iOS 11.8.0.8 "                       "                        "
> BAD:  iPad Mini 2 (ARM64), Xamarin.iOS 11.6.1.3 (xamarin-macios branch: xcode9.2 commit: f70a1348)
> BAD:  iPhone 4    (ARMv7), Xamarin.iOS 11.6.1.3 "                       "                        "



## Additional testing environment info (brief)

iPhone 4, iOS 7.1.2
iPad Mini 2, iOS 8.0

Mono 5.8.0.108 (2017-10/9aa78573ee2)
Xcode 9.0 (13247), Build 9A235
macOS 10.12.6
Comment 49 Vincent Dondain [MSFT] 2018-02-06 18:47:10 UTC
A similar (yet simpler) way to work around the build error from Comment 34 is to move the `System.Runtime.CompilerServices.Unsafe.dll` from:

`/Users/vidondai/.nuget/packages/system.runtime.compilerservices.unsafe/4.4.0/lib/netstandard2.0/` to `/Users/vidondai/.nuget/packages/system.runtime.compilerservices.unsafe/4.4.0/ref/netstandard2.0/`

This way we can build with VSMac.
Comment 50 Zoltan Varga 2018-02-06 19:30:43 UTC
I can reproduce this now with the changes from comment #49, its still present in x.ios 11.8 (d15-6).
Comment 51 Brendan Zagaeski (Xamarin Team, assistant) 2018-02-06 20:23:05 UTC
For the sake of thorough documentation, I will add to Comment 50 with my verbose results for the test case from Comment 32.




## Verification status for Comment 32: fixed on ARMv7 with Xamarin.iOS 11.8 (which matches Comment 30), but ARM64 now fails in a different way (with nullable types, as mentioned in earlier comments)

> BAD:  iPad Mini 2 (ARM64), Xamarin.iOS 11.8.0.8 (xamarin-macios branch: d15-6    commit: eaff169d)
> GOOD: iPhone 4    (ARMv7), Xamarin.iOS 11.8.0.8 "                       "                        "
> BAD:  iPad Mini 2 (ARM64), Xamarin.iOS 11.6.1.3 (xamarin-macios branch: xcode9.2 commit: f70a1348)
> BAD:  iPhone 4    (ARMv7), Xamarin.iOS 11.6.1.3 "                       "                        "



## BAD results with ARM64 on Xamarin.iOS 11.8.0.8

The application _hits_ an exception and produces the following output:

> Adding data to OkNullableEntities (4 fields with nullable) : OK
> Adding data to OkNullableEntities(14 fields without nullable) : OK
> Adding data to BuggedNullableEntities (5 fields with nullable) : ERROR
> 
> System.ExecutionEngineException: Attempting to JIT compile method
>   '(wrapper runtime-invoke)
>   <Module>:runtime_invoke_void__this___int_Nullable`1<long>_Nullable`1<long>_Nullable`1<long>_Nullable`1<long>
>   (object,intptr,intptr,intptr)' while running in aot-only mode.



## GOOD results with ARMv7 on Xamarin.iOS 11.8.0.8

The application does _not_ hit any exceptions and produces the following output:

> Adding data to OkNullableEntities (4 fields with nullable) : OK
> Adding data to OkNullableEntities(14 fields without nullable) : OK
> Adding data to BuggedNullableEntities (5 fields with nullable) : OK
> Adding data to BuggedNotNullableEntities (15 fields without nullable) : OK



## BAD results with ARMv7 and ARM64 on Xamarin.iOS 11.6.1.3 

The application _hits_ an exception and produces the following output.  The exception is the same on both ARMv7 and ARM64.

> Adding data to OkNullableEntities (4 fields with nullable) : OK
> Adding data to OkNotNullableEntities (14 fields without nullable) : ERROR
> 
> System.ExecutionEngineException: Attempting to JIT compile method
>   '(wrapper runtime-invoke)
>   <Module>:runtime_invoke_void__this___int_byte_byte_byte_byte_byte_byte_byte_byte_byte_byte_byte_byte_byte
>   (object,intptr,intptr,intptr)'



## Steps followed to test Comment 32

1. `git clone https://github.com/loic-montagne/AppBug59184`

2. Open AppBug59184.sln in Visual Studio for Mac.

3. Edit the Info.plist for the iOS app to change the "Deployment Target" to "7.0".

4. Build and run the application in the "Debug|iPhone" configuration.

5. Change the `DisplayAlert()` calls in App.xaml.cs to `Console.WriteLine()` for easier copy-pasting of error messages, and for compatibility with my old iPhone 4, iOS 7.1.2 device.
Comment 52 Zoltan Varga 2018-02-06 23:05:41 UTC
https://github.com/mono/mono/pull/6826
Comment 53 Manuel de la Peña [MSFT] 2018-02-09 17:29:58 UTC
Setting to in progress and taking it over since, although it landed in mono it was not yet added to Xamarin.iOS. I'll make sure that this is closed once we use the version of mono that contains the fix.
Comment 54 Benjamin Broll 2018-02-10 09:38:33 UTC
Manuel, any idea when that might be? We have just started to use EFCore and I need to make a decision whether we need to revert the persistence implementation and go with something else instead. If this landed in the next Xam.iOS beta and if that was around the corner, I'd wait it out :-)
Comment 55 Manuel de la Peña [MSFT] 2018-02-12 11:28:23 UTC
@Benjmin we will be using the fix provided by @zoltan in mono. Let me ask when will mono be bump in Xamarin.iOS to give you a specific date. Once we know aprox dates, those might not be written on stone, you will be able to make a decision.
Comment 56 Benjamin Broll 2018-02-13 19:19:27 UTC
@Manuel, thanks for checking!
Comment 57 Manuel de la Peña [MSFT] 2018-02-16 17:40:35 UTC
After the merge of https://github.com/xamarin/xamarin-macios/pull/3421 I have tested the sample test project with the above env following the work around in https://bugzilla.xamarin.com/show_bug.cgi?id=59184#c49 and the instructions in https://bugzilla.xamarin.com/show_bug.cgi?id=59184#c51, the app output is 

2018-02-16 18:34:43.028 AppBug59184.iOS[318:99856] Success
2018-02-16 18:34:43.071 AppBug59184.iOS[318:99856] Success
2018-02-16 18:34:43.099 AppBug59184.iOS[318:99856] Success
2018-02-16 18:34:43.116 AppBug59184.iOS[318:99856] Success
2018-02-16 18:34:43.130 AppBug59184.iOS[318:99856] refreshPreferences: HangTracerEnabled: 1
2018-02-16 18:34:43.130 AppBug59184.iOS[318:99856] refreshPreferences: HangTracerDuration: 500
2018-02-16 18:34:43.130 AppBug59184.iOS[318:99856] refreshPreferences: ActivationLoggingEnabled: 0 ActivationLoggingTaskedOffByDA:0

Env: https://gist.github.com/mandel-macaque/1814ceebe896d404c4858191984c0bce

Closing bug since it was fixed in master.
Comment 58 Brendan Zagaeski (Xamarin Team, assistant) 2018-02-23 22:36:28 UTC
## Bookkeeping note

I have updated the target milestone field to 15.7 to reflect the current plans for the release that will include the pull request from Comment 57.

Note You need to log in before you can comment on or make changes to this bug.