First, many thanks to Mark Gravel of the author protobuf-net http://code.google.com/p/protobuf-net/ . This is a really great resource. Anyway, I hope that Mark or someone else can help me resolve this exception.
I am trying to implement protobuf-net on mobile devices (iOS and Android) using the Unity3D game engine. Unity 3.2 uses Mono 2.6, their slightly modified version of mono.
It works fine in the editor, but on the iOS device at runtime it fails in the first member that it tries to serialize. Note the -aot-only flag in the exception. I think Unity basically creates an ARM assembly through the Mono aot function, although I donβt understand what it does under the hood.
ExecutionEngineException: Attempting to JIT compile method 'ProtoBuf.Property.Property`2<GameManagerSaveState , bool>:.ctor ()' while running with --aot-only. at ProtoBuf.Property.PropertyBoolean`1[GameManagerSaveState]..ctor () [0x00000] in <filename unknown>:0 at ProtoBuf.Property.PropertyFactory.CreateProperty[GameManagerSaveState] (System.Type type, ProtoBuf.DataFormat& format, MemberSerializationOptions options) [0x00000] in <filename unknown>:0 at ProtoBuf.Property.PropertyFactory.Create[GameManagerSaveState] (System.Reflection.MemberInfo member) [0x00000] in <filename unknown>:0 at ProtoBuf.Serializer`1[GameManagerSaveState].Build () [0x00000] in <filename unknown>:0
The IRC suggested that I could declare variables of these types in advance that the compiler would not need to JIT them at runtime. Sounds like a great idea, but unfortunately they look like internal generic types and don't know what to write in C # to declare variables, to fake the compiler. Can someone interpret the above message and tell me what the compiler should know in advance? Any other strategies to prevent this? BTW Here is the top of the class where the error
using UnityEngine; using System; using System.Collections; using System.Collections.Generic; using ProtoBuf; [ProtoContract] public class GameManagerSaveState { [ProtoMember(1)] public bool gameOver;
Thanks to Mono and the proto-boof experts for helping me nail this one! protobuf-net seems to be an amazing and lightweight serialization protocol and RPC protocol that is perfect for iOS and Android applications, so I'm looking forward to using it.
source share