2

I have built the very same code base with the latest Xamarin 4 tools (Xamarin Studio 5.10.1, Xamarin iOS 9.2.1, Mono MDK 4.2.1) on Mac and the latest Xamarin 3 (Xamarin Studio 5.9.8.0, Xamarin.iOS 9.1.0.31, Mono MDK 4.0.5.1) tools.

The Xamarin 3 builds work just fine, the Xamarin 4 do not. Here is the AOT problem produced by the MS ADAL library:

System.ExecutionEngineException: Attempting to JIT compile method 
'(wrapper runtime-invoke) <Module>:runtime_invoke_bool_Nullable`1<DateTimeOffset> (object,intptr,intptr,intptr)' 
while running with --aot-only. 
See http://docs.xamarin.com/ios/about/limitations for more information.

And the complete stacktrace:

System.Reflection.MonoMethod.Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
System.Reflection.MethodBase.Invoke(object obj, object[] parameters)
System.Runtime.Serialization.Json.JsonFormatWriterInterpreter.UnwrapNullableObject(Func<_> memberValue, ref Type memberType, ref bool isNull)
System.Runtime.Serialization.Json.JsonFormatWriterInterpreter.WriteValue(Type memberType, object memberValue)
System.Runtime.Serialization.Json.JsonFormatWriterInterpreter.WriteMembers(ClassDataContract classContract, ExtensionDataObject extensionData, ClassDataContract derivedMostClassContract)
System.Runtime.Serialization.Json.JsonFormatWriterInterpreter.WriteClass(ClassDataContract classContract)
System.Runtime.Serialization.Json.JsonFormatWriterInterpreter.WriteToJson(XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContextComplexJson context, ClassDataContract dataContract, XmlDictionaryString[] memberNames)
System.Runtime.Serialization.Json.JsonFormatWriterGenerator.CriticalHelper.<GenerateClassWriter>c__AnonStorey0.<>m__0(XmlWriterDelegator xmlWriter, object obj, XmlObjectSerializerWriteContextComplexJson context, ClassDataContract dataContract, XmlDictionaryString[] memberNames)
System.Runtime.Serialization.Json.JsonClassDataContract.WriteJsonValueCore(XmlWriterDelegator jsonWriter, object obj, XmlObjectSerializerWriteContextComplexJson context, RuntimeTypeHandle declaredTypeHandle)
System.Runtime.Serialization.Json.JsonDataContract.WriteJsonValue(XmlWriterDelegator jsonWriter, object obj, XmlObjectSerializerWriteContextComplexJson context, RuntimeTypeHandle declaredTypeHandle)
System.Runtime.Serialization.Json.DataContractJsonSerializer.WriteJsonValue(JsonDataContract contract, XmlWriterDelegator writer, object graph, XmlObjectSerializerWriteContextComplexJson context, RuntimeTypeHandle declaredTypeHandle)
System.Runtime.Serialization.Json.XmlObjectSerializerWriteContextComplexJson.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, object obj, RuntimeTypeHandle declaredTypeHandle)
System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithoutXsiType(DataContract dataContract, XmlWriterDelegator xmlWriter, object obj, RuntimeTypeHandle declaredTypeHandle)
System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, object obj, bool isDeclaredType, bool writeXsiType, int declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
System.Runtime.Serialization.XmlObjectSerializerWriteContextComplex.InternalSerialize(XmlWriterDelegator xmlWriter, object obj, bool isDeclaredType, bool writeXsiType, int declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerializeReference(XmlWriterDelegator xmlWriter, object obj, bool isDeclaredType, bool writeXsiType, int declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
System.Reflection.MonoMethod.InternalInvoke(MonoMethod, object, object[], ref Exception)(wrapper managed-to-native)
System.Reflection.MonoMethod.Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.<AcquireTokenCommonAsync>d__68.MoveNext()
Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext.<AcquireTokenAsync>d__4b.MoveNext()

I would appreciate any constructive explanation of what has changed and why this this thing is no longer working.

Is this related to some Mono implementation change or some weird mtouch behaviour?

Gabor
  • 1,656
  • 1
  • 16
  • 28
  • Gabor I have the same issue as you, could you fix it? – Fran_gg7 Dec 04 '15 at 07:58
  • @Fran_gg7, nope I just reverted back to the previous version of the toolset (but you can upvote the question if you find the proplem relevant). As poupou pointed out this is probably a bug, so I will report it shortly. – Gabor Dec 05 '15 at 21:54

2 Answers2

1

Solution: Please file a bug report, on http://bugzilla.xamarin.com, along with a test case. There very little probability that anyone on stackoverflow can help with such specific issues.

As to why ? it's likely the move from Mono code (mono 4.0 was used in XI 9.1) to the MS RS code (open sourced .NET BCL used in mono 4.2 and XI 9.2) that hits a case that the AOT compiler does not handle.

A test case will help us identify and fix that code. More importantly it also makes great addition to our unit tests (to ensure further changes won't break this again).

poupou
  • 43,413
  • 6
  • 77
  • 174
0

I had the same problem. After lots of time spending, I found that app.config was missing from my project file. Adding that file to my project solved that issue. Let me know if this works!