I'm getting this exception on Xamarin.iOS 6.4.3.0. This code used to work fine in Xamarin.iOS 6.2.x, but now throws this error in 6.4.x.
I know that there are limitations with JIT compiling on iOS, so my code looks like this:
protected class SWIGStringHelper {
public delegate string SWIGStringDelegate(string message);
static SWIGStringDelegate stringDelegate = new SWIGStringDelegate(CreateString);
[DllImport("__Internal", EntryPoint="SWIGRegisterStringCallback_psconnectul")]
public static extern void SWIGRegisterStringCallback_psconnectul(SWIGStringDelegate stringDelegate);
[MonoTouch.MonoPInvokeCallback (typeof (SWIGStringDelegate))]
static string CreateString(string cString) {
return cString;
}
static SWIGStringHelper() {
SWIGRegisterStringCallback_psconnectul(stringDelegate);
}
}
It seems like something is broken with the [MonoPInvokeCallback] attribute. Is there a workaround for this or a fix in the pipeline? Please advise.
Full exception:
InnerException {System.ExecutionEngineException: Attempting to JIT compile method '(wrapper native-to-managed)
PointSync.Connect.Ultralite.Native.psconnectulPINVOKE/SWIGStringHelper:CreateString (intptr)' while running
with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.
at (wrapper managed-to-native) object:__icall_wrapper_mono_delegate_to_ftnptr (object)
at (wrapper managed-to-native) PointSync.Connect.Ultralite.Native.psconnectulPINVOKE/SWIGStringHelper:SWIGRegisterStringCallback_psconnectul
(PointSync.Connect.Ultralite.Native.psconnectulPINVOKE/SWIGStringHelper/SWIGStringDelegate)
at PointSync.Connect.Ultralite.Native.psconnectulPINVOKE+SWIGStringHelper..cctor () [0x00000]
in <filename unknown>:0 }
System.ExecutionEngineException