AOT 问题消息 Attempting to JIT compile method with Pinvoke on Xamarin iOS
AOT issue with message Attempting to JIT compile method with Pinvoke on Xamarin iOS
我正面临消息 Attempting to JIT compile method '(wrapper managed-to-native) ;...wrapper_aot_native (object)' while 运行 --aot-只有.
我有一个包含方法指针的结构,应该由本机函数(称为 LoadContext)初始化,这个结构看起来像这样:
[StructLayout (LayoutKind.Sequential)]
public struct WrapperContext
{
public int ctxVersion;
public unsafe GetLibraryVersionXDelegate GetLibraryVersion;
public unsafe GetLibraryDateXDelegate GetLibraryDate;
public unsafe InitCallbackTableXDelegate InitCallbackTable;
.....
}
当我调用应该初始化 WrapperContext 结构的 LoadContext 本机方法时,运行时抛出了以下异常:
Attempting to JIT compile method '(wrapper managed-to-native) XXXXX.XXXXXX.XXXXX.GetLibraryVersionXDelegate:wrapper_aot_native (object)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.
为了解决这个问题,我创建了另一个结构,其中包含完全相同的字段列表,但将委托类型替换为 IntPtr:
[StructLayout (LayoutKind.Sequential)]
public struct WrapperContext2
{
public int ctxVersion;
public IntPtr GetLibraryVersionXDelegate GetLibraryVersion;
public IntPtr GetLibraryDateXDelegate GetLibraryDate;
public IntPtr InitCallbackTableXDelegate InitCallbackTable;
.....
}
现在,对我的本机 LoadContext 的调用工作正常,我得到了每个函数的指针,但是当尝试使用 Marshal.GetFunctionPointerForDelegate() 将函数指针转换为其委托表示时,出现完全相同的异常被运行时抛出:
Attempting to JIT compile method '(wrapper managed-to-native) XXXXX.XXXXXX.XXXXX.GetLibraryVersionXDelegate:wrapper_aot_native (object)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.
感谢您的帮助。
我终于通过在每个委托定义上添加 UnmanagedFunctionPointer 属性解决了这个问题:
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public unsafe delegate IntPtr GetLibraryVersionXDelegate();
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public unsafe delegate IntPtr GetLibraryDateXDelegate();
希望这对其他人有帮助。
我正面临消息 Attempting to JIT compile method '(wrapper managed-to-native) ;...wrapper_aot_native (object)' while 运行 --aot-只有.
我有一个包含方法指针的结构,应该由本机函数(称为 LoadContext)初始化,这个结构看起来像这样:
[StructLayout (LayoutKind.Sequential)]
public struct WrapperContext
{
public int ctxVersion;
public unsafe GetLibraryVersionXDelegate GetLibraryVersion;
public unsafe GetLibraryDateXDelegate GetLibraryDate;
public unsafe InitCallbackTableXDelegate InitCallbackTable;
.....
}
当我调用应该初始化 WrapperContext 结构的 LoadContext 本机方法时,运行时抛出了以下异常:
Attempting to JIT compile method '(wrapper managed-to-native) XXXXX.XXXXXX.XXXXX.GetLibraryVersionXDelegate:wrapper_aot_native (object)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.
为了解决这个问题,我创建了另一个结构,其中包含完全相同的字段列表,但将委托类型替换为 IntPtr:
[StructLayout (LayoutKind.Sequential)]
public struct WrapperContext2
{
public int ctxVersion;
public IntPtr GetLibraryVersionXDelegate GetLibraryVersion;
public IntPtr GetLibraryDateXDelegate GetLibraryDate;
public IntPtr InitCallbackTableXDelegate InitCallbackTable;
.....
}
现在,对我的本机 LoadContext 的调用工作正常,我得到了每个函数的指针,但是当尝试使用 Marshal.GetFunctionPointerForDelegate() 将函数指针转换为其委托表示时,出现完全相同的异常被运行时抛出:
Attempting to JIT compile method '(wrapper managed-to-native) XXXXX.XXXXXX.XXXXX.GetLibraryVersionXDelegate:wrapper_aot_native (object)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.
感谢您的帮助。
我终于通过在每个委托定义上添加 UnmanagedFunctionPointer 属性解决了这个问题:
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public unsafe delegate IntPtr GetLibraryVersionXDelegate();
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public unsafe delegate IntPtr GetLibraryDateXDelegate();
希望这对其他人有帮助。