msgpack / msgpack-cli

MessagePack implementation for Common Language Infrastructure / msgpack.org[C#]
http://msgpack.org
Apache License 2.0
835 stars 175 forks source link

AOT error can not be avoided. #216

Open st0326s opened 7 years ago

st0326s commented 7 years ago

When I executed the following code with actual machine, I got an AOT error.

Please tell me how to fix the error.

●Error Message Attempting to call method 'MsgPack.Serialization.SerializationContext::GetSerializer' for which no ahead of time (AOT) code was generated

●Code of error occurrence part

var deserializer = MessagePackSerializer.Get<Response>();

●Code I tried

MessagePackSerializer.PrepareType<Response>() 
var deserializer = MessagePackSerializer.Get<Response>();

But I got the same error.

●Use Dll URL=https://github.com/msgpack/msgpack-cli/releases

MsgPack.Cli.0.8.1.zip

●MsgPack.dll used for testing Folder is MsgPack.Cli.0.8.1\unity Folder is MsgPack.Cli.0.8.1\unity-full

But I got the same error.

●Code details The value "byte[] wwwBytes" of the "SuccessMsgpack" method contains the communication response www.bytes

●Excerpt of implemented code

    public class Response
    {
        public string releaseDatetime;
        public string userId;
    }

    public override void SuccessMsgpack(byte[] wwwBytes)
    {
        MemoryStream stream = new MemoryStream(wwwBytes);

        var deserializer = MessagePackSerializer.Get<Response>();
        object value = deserializer.Unpack(stream);

        Response dataClass = (Response)value;

        Debug.Log("ReleaseDatetime=" + dataClass.releaseDatetime);
        Debug.Log("UserId=" + dataClass.userId);
    }

●Development environment Unity5.5.1p1 Xcode8.2

●Test environment iPhone5se iOS8

yfakariya commented 7 years ago

Thank you for reporting. I will investigate it and provide workaround or fix it.

st0326s commented 7 years ago

Thank you for the reply.

I will wait for it to be fixed

Currently I can not convert to class It converts it to a key value type, and extracts a value from there.

If this is the case, the correction cost is high, so I'd like to convert it to class somehow.

For Example

public override void SuccessMsgpack(byte[] wwwBytes)
{
    MemoryStream stream = new MemoryStream(wwwBytes);
    var rawObject = MessagePackSerializer.UnpackMessagePackObject( stream );
    var dataDic = rawObject.AsDictionary ();
    Response dataClass = new Response ();

    dataClass.releaseDatetime = (string)dataDic ["releaseDatetime"];
    dataClass.userId = (string)dataDic ["userId"];
}
yfakariya commented 7 years ago

@st0326s Sorry for delay to tackle this problem, but I failed to reproduce your issue. Would you put actual stack trace or more info about build? I tried with:

yfakariya commented 7 years ago

One more question. What script backend did you use?(IL2CPP or mono 2.x)

st0326s commented 7 years ago

Sorry to be late replying.

There is no doubt the thing used below.

Unity 5.5.1 p1 Launch XCode as: Release Checkboxes (I tried following combinatations): Development build: off, Script Debugging: off Development build: on, Script Debugging: on MsgPack.dll from 0.8.1.zip

And I built it with IL2CPP.

Do you have any information?

yfakariya commented 7 years ago

Thank you, but I have no ideas of it...