Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

249
Vistas
C# Mono aot with protobuf-net getting ExecutionEngineException

First a big thanks to Marc Gravell author of protobuf-net http://code.google.com/p/protobuf-net/ . It's a really great resource. Anyhow I am hoping that Marc or someone else can help me resolve this exception.

I am trying to implement protobuf-net on mobile devices (iOS and Android) using 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 at the first member it tries to serialize. Note the --aot-only flag in the exception. I think Unity basically builds ARM assembly through Mono's aot feature though I don't understand what it's doing 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

It was suggested on IRC that I could declare variables of these types ahead of time, that the compiler would not have to JIT them at runtime. Seems like a great idea, but unfortunately these are like internal generic types, and don't know what to write in C# to declare variables in order to fake out the compiler. Can anyone interpret the above message and let me know what the compiler needs to know in advance? Any other strategies for preventing this from happening? BTW Here is the top of the class where it's erroring

using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using ProtoBuf;

[ProtoContract]
public class GameManagerSaveState
{
    [ProtoMember(1)]
    public bool gameOver;
      // snip

Thanks Mono and protobuf experts for helping me nail this one! protobuf-net seems to be an awesome and lightweight serialization and RPC wire protocol that would be perfect for iOS and Android apps, so I am looking forward to using it.

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

There are a number of issues in v1 that make it a bit of a pain to pre-JIT; v2, although incomplete, is intended to resolve many/all of these issues, not least by offering a pre-compile to dll option - but even the runtime-only version should be much more device friendly.

I should also mention that Jon's port of the Java version should work well here, since it is compiler-heavy rather than runtime-heavy.

over 4 years ago · Santiago Trujillo Denunciar

0

Use this before using protobuf:

Environment.SetEnvironmentVariable("MONO_REFLECTION_SERIALIZER", "yes");

Credit: https://github.com/antonholmquist/easy-serializer-unity

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda