here are the 5 lines trying to get informations about some random 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);
Last line (oDict.GetArray()) crashes like this:
Native stacktrace:
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
Any hints ?
It's not your fault, this is a MonoTouch bug.
CGPDFDictionary is being created with the CGPDFPage handle (while it should have been created with a call to CGPDFPageGetDictionary on the CGPDFPage handle).
You can workaround this bug by adding the pinvoke in your app:
[System.Runtime.InteropServices.DllImport ("/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics")]
private static extern IntPtr CGPDFPageGetDictionary (IntPtr pageHandle);
and the creating the dictionary yourself:
IntPtr handle = CGPDFPageGetDictionary (oPage.Handle);
MonoTouch.CoreGraphics.CGPDFDictionary oDict = new MonoTouch.CoreGraphics.CGPDFDictionary (handle);