Skip to content

iOS: Attempting to JIT compile method '(wrapper dynamic-method) void object:WriteArrayOfintToXml (System.Runtime.Serialization.XmlWriterDelegator,object,System.Runtime.Serialization.XmlObjectSerializerWriteContext,System.Runtime.Serialization.CollectionDataContract)' while running in aot-only mode. #47114

@rolfbjarne

Description

@rolfbjarne

Description

The following code throws an exception at runtime when running on an iOS device:

var ds = new DataContractSerializer (typeof (IEnumerable<int>));
using (var xw = XmlWriter.Create (System.IO.Stream.Null))
	ds.WriteObject (xw, new int [] { 1, 2, 3 });

Exception:

System.ExecutionEngineException: Attempting to JIT compile method '(wrapper dynamic-method) void object:WriteArrayOfintToXml (System.Runtime.Serialization.XmlWriterDelegator,object,System.Runtime.Serialization.XmlObjectSerializerWriteContext,System.Runtime.Serialization.CollectionDataContract)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.
    at System.Delegate.CreateDelegate(Type type, Object firstArgument, MethodInfo method, Boolean throwOnBindFailure, Boolean allowClosed)
    at System.Delegate.CreateDelegate(Type type, Object firstArgument, MethodInfo method, Boolean throwOnBindFailure)
    at System.Delegate.CreateDelegate(Type type, Object firstArgument, MethodInfo method)
    at System.Reflection.Emit.DynamicMethod.CreateDelegate(Type delegateType)
    at System.Runtime.Serialization.CodeGenerator.EndMethod()
    at System.Runtime.Serialization.XmlFormatWriterGenerator.CriticalHelper.GenerateCollectionWriter(CollectionDataContract collectionContract)
    at System.Runtime.Serialization.XmlFormatWriterGenerator.GenerateCollectionWriter(CollectionDataContract collectionContract)
    at System.Runtime.Serialization.CollectionDataContract.CreateXmlFormatWriterDelegate()
    at System.Runtime.Serialization.CollectionDataContract.get_XmlFormatWriterDelegate()
    at System.Runtime.Serialization.CollectionDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
    at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle)
    at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeAndVerifyType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, Boolean verifyKnownType, RuntimeTypeHandle declaredTypeHandle, Type declaredType)
    at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiTypeAtTopLevel(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle originalDeclaredTypeHandle, Type graphType)
    at System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
    at System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
    at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
    at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph)
    at System.Runtime.Serialization.DataContractSerializer.WriteObject(XmlWriter writer, Object graph)
    at MySingleView.AppDelegate.FinishedLaunching(UIApplication app, NSDictionary options) in /Users/rolf/work/maccore/onedotnet/xamarin-macios/tests/dotnet/MySingleView/AppDelegate.cs:line 45

Repro:

git clone https://github.com/rolfbjarne/xamarin-macios
cd xamarin-macios
git checkout dotnet-attempting-to-jit-compile-method-WriteArrayOfintToXml
./configure --enable-dotnet
make reset
make all -j8
make install -j8
make singleview -C tests/dotnet

Complete output

Configuration

.NET 6.0.100-alpha.1.21060.3

Binlog:
MySingleView.binlog.zip

Regression?

No (new feature)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions