c# - MonoTouch native 崩溃调用 CGPDFDictionary.GetArray

标签 c# ios mono xamarin.ios cgpdfdictionaryref

这是试图获取有关某些随机 PDF 的信息的 5 行代码:

        MonoTouch.CoreGraphics.CGPDFDocument oDoc = MonoTouch.CoreGraphics.CGPDFDocument.FromUrl("http://www.attachmate.com/NR/rdonlyres/C7BBC53C-CF9B-4C9C-AC3F-6C166526EC12/0/IDC_Attachmate_NetIQOverview2007.pdf");
        MonoTouch.CoreGraphics.CGPDFPage oPage = oDoc.GetPage(1);
        MonoTouch.CoreGraphics.CGPDFDictionary oDict = oPage.Dictionary;
        MonoTouch.CoreGraphics.CGPDFArray oArray;
        bool bResult = oDict.GetArray("Annots", out oArray);

最后一行 (oDict.GetArray()) 像这样崩溃:

native 堆栈跟踪:

0   Test_MT1                            0x000d1965 mono_handle_native_sigsegv + 343
1   Test_MT1                            0x0000ffb4 mono_sigsegv_signal_handler + 322
2   libSystem.B.dylib                   0x94a9705b _sigtramp + 43
3   ???                                 0xffffffff 0x0 + 4294967295
4   CoreGraphics                        0x01055068 compare_key + 34
5   libSystem.B.dylib                   0x94a5f63d bsearch + 41
6   CoreGraphics                        0x010552a1 CGPDFDictionaryGetObject + 74
7   CoreGraphics                        0x010553fa CGPDFDictionaryGetArray + 31
8   ???                                 0x0ca253f6 0x0 + 211964918

有什么提示吗?

最佳答案

这不是你的错,这是一个 MonoTouch 错误。

CGPDFDictionary 是使用 CGPDFPage 句柄创建的(虽然它应该是通过调用 CGPDFPage 句柄上的 CGPDFPageGetDictionary 创建的)。

您可以通过在您的应用中添加 pinvoke 来解决此错误:

[System.Runtime.InteropServices.DllImport ("/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics")]
private static extern IntPtr CGPDFPageGetDictionary (IntPtr pageHandle);

以及自己创建字典:

IntPtr handle = CGPDFPageGetDictionary (oPage.Handle);
    MonoTouch.CoreGraphics.CGPDFDictionary oDict = new MonoTouch.CoreGraphics.CGPDFDictionary (handle);

关于c# - MonoTouch native 崩溃调用 CGPDFDictionary.GetArray,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6486673/

相关文章:

c# - 采用 IDisposable 模式

ios - 在 iOS 中管理动画

objective-c - 使用 transient 属性时需要什么原语?

c# - 如何将 BYTE* 发送到与 SendMessage 互操作的 c#?

c# - SignalR 和类型化对象

c# - 转换运算符仅适用于数字类型.net

macos - mac mono fiddler 在执行 native 代码时得到了一个 SIGSEGV

ios - Xamarin IOS 应用程序仅在安装 itunesconnect 和物理设备后崩溃

c# - 在 Amazon Linux 上安装 mono 时出错

c# - Mono.Security加载问题