Calling System.Reflection.PropertyInfo.GetValue on an AOT compiled platform when the API compatibility level is set to .NET 2.0 gives me the following error:
Unhandled Exception: System.ExecutionEngineException: Attempting to JIT compile method ‘System.Reflection.MonoProperty:StaticGetterAdapterFrame (System.Reflection.MonoProperty/StaticGetter`1,object)’ while running with --aot-only.
at System.Reflection.MonoProperty.GetValue (System.Object obj, System.Object index) [0x00000] in :0
The error does not occur when the API compatibility level is set to .NET 2.0 Subset. Is this expected behaviour or a Unity bug?
Here is my code
void Start()
{
System.Type type = System.Type.GetType("UnityEngine.iPhone, UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
if (type != null)
{
System.Reflection.PropertyInfo property = type.GetProperty("generation");
if (property != null)
{
string text = property.GetValue(null, null).ToString().ToLower();
Debug.Log("text = " + text);
}
else
Debug.Log("property = null");
}
}
This was added to a new empty project in Unity 4.5.5 and deployed to a 1st generation iPad Mini running iOS 7.1.2.