JIT compile error with protobuf-net on MonoTouch/i

2019-02-19 04:17发布

I am using protobuf-net v2 beta r450 (binary distribution) and building a serialization assembly ahead of time using the technique described here:

http://www.frictionpointstudios.com/blog/2011/3/31/using-protobuf-net-serialization-in-unity-iphone.html

I create my serialization assembly on Windows and use it in my MonoTouch project. It works under the simulator. But when run on the device, where AOT compilation only is enforced, I get this error:

attempting to JIT compile method 'ProtoBuf.BufferPool.GetBuffer()' 
while running with --aot-only 

The exception occurs when Serialize() is called:

using (var stream = File.Create(out_file))
{
    serializer.Serialize(stream, settings);
}

Thanks for any help.

2条回答
神经病院院长
2楼-- · 2019-02-19 04:34

I had an almost similar problem when working with unity (with protobuf-net and iOS), this helped me:

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

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

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-02-19 04:42

I grabbed the protobuf-net sources (v2 r470). Use of [ImmutableObject] was indeed one of the issues. I submitted a few minor patches to @MarcGravell via the protobuf-net issue list. I have updated my example at http://github.com/t9mike/ProtoBuf1 with this new assembly. Thanks everyone for the responses.

查看更多
登录 后发表回答