我有一个使用Xamarin iOS构建的iOS应用程序在加载具有PInvoke调用的DllImport属性的类时崩溃。例外是:
Unhandled managed exception: An exception was thrown by the type initializer for Pazanga.Native.ZzPINVOKE (System.TypeInitializationException)
该应用程序运行良好,但在本机库大小增加时开始崩溃。在裁剪了库的某些部分后,它再次工作,但在链接新库后,它又开始崩溃了。在实际对本机库进行任何调用之前发生崩溃。
以下是崩溃后的设备日志:http://pastebin.com/vW3CMXHq
内部例外是:
Aug 23 10:33:40 Outboxs-iPod pazanga[4216] <Warning>: System.TypeInitializationException: An exception was thrown by the type initializer for Pazanga.Native.ZzPINVOKE ---> System.TypeInitializationException: An exception was thrown by the type initializer for SWIGStringHelper ---> System.ExecutionEngineException: Attempting to JIT compile method '(wrapper native-to-managed) Pazanga.Native.ZzPINVOKE/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) Pazanga.Native.ZzPINVOKE/SWIGStringHelper:SWIGRegisterStringCallback_Zz (Pazanga.Native.ZzPINVOKE/SWIGStringHelper/SWIGStringDelegate)
at Pazanga.Native.ZzPINVOKE+SWIGStringHelper..cctor () [0x00017] in /Users/max/Code/pazanga/mobile/ios/bindings/ZzPINVOKE.cs:229
--- End of inner exception stack trace ---
at Pazanga.Native.ZzPINVOKE..cctor () [0x0000a] in /Users/max/Code/pazanga/mobile/ios/bindings/ZzPINVOKE.cs:233
--- End of inner exception stack trace ---
at Pazanga.Native.Zz.locate (System.Byte[] image, image_format format, Int32 width, Int32 height, Int32 x, Int32 y) [0x00009] in /Users/max/Code/pazanga/mobile/ios/bindings/Zz.cs:16
at Pazanga.CaptureDecode.ProcessFrame (System.Byte[] data, Int32 dataWidth, Int32 dataHeight, Boolean isPicture) [0x000cf] in /Users/max/Code/pazanga/mobile/common/CaptureDecode.cs:95
at Pazanga.iOS.CaptureViewController.HandleNewFrame (System.Byte[] data, Int32 width, Int32 height) [0x0003b] in /Users/max/Code/pazanga/mobile/ios/App/CaptureViewController.cs:128
at Pazanga.iOS.CaptureManager.OnNewFrame (System.Byte[] array, Int32 width, Int32 height) [0x00015] in /Users/max/Code/pazanga/mobile/ios/App/CaptureManager.cs:126
at Pazanga.iOS.CaptureManager+OutputDelegate.DidOutputSampleBuffer (MonoTouch.AVFoundation.AVCaptureOutput captureOutput, MonoTouch.CoreMedia.CMSampleBuffer sampleBuffer, MonoTouch.AVFoundation.AVCaptureConnection connection) [0x000c6] in /Users/max/Code/pazanga/mobile/ios/App/CaptureManager.cs:110
Aug 23 10:33:40 Outboxs-iPod pazanga[4216] <Warning>: System.TypeInitializationException: An exception was thrown by the type initializer for SWIGStringHelper ---> System.ExecutionEngineException: Attempting to JIT compile method '(wrapper native-to-managed) Pazanga.Native.ZzPINVOKE/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) Pazanga.Native.ZzPINVOKE/SWIGStringHelper:SWIGRegisterStringCallback_Zz (Pazanga.Native.ZzPINVOKE/SWIGStringHelper/SWIGStringDelegate)
at Pazanga.Native.ZzPINVOKE+SWIGStringHelper..cctor () [0x00017] in /Users/max/Code/pazanga/mobile/ios/bindings/ZzPINVOKE.cs:229
--- End of inner exception stack trace ---
at Pazanga.Native.ZzPINVOKE..cctor () [0x0000a] in /Users/max/Code/pazanga/mobile/ios/bindings/ZzPINVOKE.cs:233
Aug 23 10:33:40 Outboxs-iPod pazanga[4216] <Warning>: System.ExecutionEngineException: Attempting to JIT compile method '(wrapper native-to-managed) Pazanga.Native.ZzPINVOKE/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) Pazanga.Native.ZzPINVOKE/SWIGStringHelper:SWIGRegisterStringCallback_Zz (Pazanga.Native.ZzPINVOKE/SWIGStringHelper/SWIGStringDelegate)
at Pazanga.Native.ZzPINVOKE+SWIGStringHelper..cctor () [0x00017] in /Users/max/Code/pazanga/mobile/ios/bindings/ZzPINVOKE.cs:229
以下是出现在异常中的SWIGStringHelper类(由SWIG生成):
protected class SWIGStringHelper {
public delegate string SWIGStringDelegate(string message);
static SWIGStringDelegate stringDelegate = new SWIGStringDelegate(CreateString);
[DllImport("__Internal", EntryPoint="SWIGRegisterStringCallback_Zz")]
public static extern void SWIGRegisterStringCallback_Zz(SWIGStringDelegate stringDelegate);
[MonoTouch.MonoPInvokeCallback(typeof(SWIGStringDelegate))]
static string CreateString(string cString) {
return cString;
}
static SWIGStringHelper() {
SWIGRegisterStringCallback_Zz(stringDelegate);
}
}
关于如何解决这个问题的任何想法?
答案 0 :(得分:2)
关闭循环......结果是bug 14194的副本(使用字符串进行反向回调)。
抛出了TypeInitializationException
,因为异常发生在静态构造函数中。