Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 调用CGPDFDictionary.GetArray的MonoTouch本机崩溃_C#_Ios_Mono_Xamarin.ios_Cgpdfdictionaryref - Fatal编程技术网

C# 调用CGPDFDictionary.GetArray的MonoTouch本机崩溃

C# 调用CGPDFDictionary.GetArray的MonoTouch本机崩溃,c#,ios,mono,xamarin.ios,cgpdfdictionaryref,C#,Ios,Mono,Xamarin.ios,Cgpdfdictionaryref,这里有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"); Mon

这里有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

有什么提示吗?

这不是你的错,这是一个单触错误

正在使用CGPDFPage句柄创建CGPDFDictionary(而它应该是通过在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);
非常感谢(得到一些确认和解决方案)!