1

我正在尝试在 Monotouch 中创建 pdf 的缩略图,但应用程序有时会崩溃并抛出以下错误。

堆栈跟踪:

at MonoTouch.CoreFoundation.CFString.Dispose () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/shared/CoreFoundation/CFString.cs:131
at MonoTouch.CoreFoundation.CFUrl.FromFile (string) [0x00048] in /Developer/MonoTouch/Source/monotouch/src/shared/CoreFoundation/CFUrl.cs:79 at MonoTouch.CoreGraphics.CGPDFDocument.FromFile (string) [0x00000] in /Developer/MonoTouch/Source/monotouch/src/shared/CoreGraphics/CGPDFDocument.cs:98

下面是我生成缩略图的代码,它们位于 BackgroundWorker 线程内。奇怪的是,它并不总是发生。有人知道为什么会这样吗?提前致谢。

try
{
    CGPDFDocument pdfDoc = CGPDFDocument.FromFile(url);
    if (pdfDoc != null)
    {
        CGPDFPage pdfPage = pdfDoc.GetPage(1);
        if (pdfPage != null)
        {
            UIImage image = PDFConverter.TransformToImage(pdfPage, this.Frame.Width);
        }
    }
}
catch (Exception ex)
{
    Console.WriteLine("BookmarkView - BookmarkView: {0}", ex.ToString());
}
4

0 回答 0