Hi,
I'm getting this error when running my game on ios.
Based on the log, the offending method is the following one:
public static bool Save (T serializeableObject, string fileName)
//public static bool Save (GameSave serializeableObject, string fileName)
{
bool ret = true;
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
bf.Serialize (ms, serializeableObject);
byte[] byteStream = ms.ToArray();
byteStream = HashAndEncrypt (byteStream);
StreamSave (byteStream, fileName);
return ret;
}
As far as I understand, the error is triggered because some reflection method is being invoked after bf.Serialize is called. I think the execution stops before calling ms.ToArray.
The commented line shows that I tried removing the generic (I only use this method with the GameSave class), but it didn't work.
GameSave itself doesn't have anything fancy in it; it does have some lists however, and specifically a bunch of `List` types: could this be an issue?
HashAndEncrypts also makes some calculations based on the length of byteStream, which is presumably unforeseeable at compile time but again, the issue seems to be before that.
As a last info, the issue luckily disappears by switching the scripting backend from mono to il2cpp. Still, I would like to understand what is happening, primarily to avoid any similar issue in the future.
↧