System.NotImplementedException: byref delegate when using MessagePacks with xamarin.forms on iOS

Viewed 168

I'm trying to implement deserialisation for MessagePacks.

I currently have a working implementation when I run my app on android. However, when I run the app on iOS, I get the following exception on runtime when hitting the deserialisation method.

System.NotImplementedException: byref delegate
System.Linq.Expressions.Interpreter
LightLambda.CreateCustomDelegate (System.Type delegateType)
System.Linq.Expressions.Interpreter
LightLambda.MakeDelegate (System.Type delegateType)
System.Linq.Expressions.Interpreter
LightDelegateCreator.CreateDelegate (System.Runtime.CompilerServices.IStrongBox[] closure)
System.Linq.Expressions.Interpreter
LightDelegateCreator.CreateDelegate ()
System.Linq.Expressions
Expression`1[TDelegate].Compile (System.Boolean preferInterpretation)
MessagePack.MessagePackSerializer+CompiledMethods
MessagePack.MessagePackSerializer+CompiledMethods..ctor (System.Type type) <0x1082e5c10 + 0x00e7b> in <7f586603e57b4990882764e9179b9d4b#7d9490cdb343bf249163494f476b29fc>:0
MessagePack.MessagePackSerializer+<>c
<.cctor>b__45_0 (System.Type t)
MessagePack.Internal
ThreadsafeTypeKeyHashTable`1[TValue].AddToBuckets (MessagePack.Internal.ThreadsafeTypeKeyHashTable`1+Entry[TValue][] buckets, System.Type newKey, MessagePack.Internal.ThreadsafeTypeKeyHashTable`1+Entry[TValue] newEntryOrNull, System.Func`2[T,TResult] valueFactory, TValue& resultingValue)
MessagePack.Internal
ThreadsafeTypeKeyHashTable`1[TValue].TryAddInternal (System.Type key, System.Func`2[T,TResult] valueFactory, TValue& resultingValue)
MessagePack.Internal
ThreadsafeTypeKeyHashTable`1[TValue].GetOrAdd (System.Type key, System.Func`2[T,TResult] valueFactory)
MessagePack
MessagePackSerializer.GetOrAdd (System.Type type)
MessagePack
MessagePackSerializer.Deserialize (System.Type type, System.IO.Stream stream, MessagePack.MessagePackSerializerOptions options, System.Threading.CancellationToken cancellationToken)
RailCube.Mobile.Http.Formatters
MessagePackInputFormatter.ReadFromStreamAsync (System.Type type, System.IO.Stream readStream, System.Net.Http.HttpContent content, System.Net.Http.Formatting.IFormatterLogger formatterLogger)
System.Net.Http.Formatting
MediaTypeFormatter.ReadFromStreamAsync (System.Type type, System.IO.Stream readStream, System.Net.Http.HttpContent content, System.Net.Http.Formatting.IFormatterLogger formatterLogger, System.Threading.CancellationToken cancellationToken)
System.Net.Http
HttpContentExtensions.ReadAsAsyncCore[T] (System.Net.Http.HttpContent content, System.Type type, System.Net.Http.Formatting.IFormatterLogger formatterLogger, System.Net.Http.Formatting.MediaTypeFormatter formatter, System.Threading.CancellationToken cancellationToken)

...


This is the method

public override Task<object> ReadFromStreamAsync(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger)
        {
            var options =
            MessagePackSerializerOptions.Standard.WithResolver(
                    CompositeResolver.Create(
                        GeneratedResolver.Instance,
                        StandardResolver.Instance
                    ));

            // Exception thrown here.
            var obj = MessagePackSerializer.Deserialize(type, readStream, options);
            
            return Task.FromResult(obj);
        }

I'm precompiling my custom types as recommended MessagePack Compiler via MSBuild Task which is working like a charm for android.

Has anybody got a clue why this exception is being thrown or what it even means? I really appreciate any help you can provide.

0 Answers
Related