I’m creating a project with Unity 4.x and am running into a problem when building the 64-bit version for iOS.
For the 64-bit version, I have to set the scripting backend to IL2CPP. However, the following code I use to acquire class names and method names:
System.Diagnostics.StackFrame frame = new System.Diagnostics.StackFrame(1);
var method = frame.GetMethod();string typeString = tempMethod.ReflectedType.ToString ();
now returns a null reference exception.
This happens for Unity 4.6.9 and 4.7.2. It works fine if I use Mono(2.x)
In other words, I can’t do a successful custom stack trace in Unity 4.6.9 or 4.7.2 when using IL2CPP for a 64-bit app.
Is there any other way I can trace the class and method name with the IL2CPP backend?
Thanks in advance!
I’m not 100% certain, but I’m pretty sure that reflection does not work with IL2CPP.
Actually scrap that, it’s only System.Relfection.Emit that’s not supported with IL2CPP.
ReflectedType() does not always have a value!!! The default of Type, “default(Type)” is null.
That will throw a null if the System.Object you are using does not extend some other System.Object. Break on that and confirm.
1 Like