2

这里有 5 行试图获取一些随机 PDF 的信息:

        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()) 像这样崩溃:

本机堆栈跟踪:

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

有什么提示吗?

4

1 回答 1

1

这不是你的错,这是一个 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);
于 2011-07-16T14:42:17.880 回答