UWP Windows 10打印例外

时间:2017-06-17 21:50:37

标签: c# printing uwp windows-10-universal

几个月前,我想在我的应用程序中添加打印功能。通过遵循微软Github的UWP Printing样本,我能够做到这一点。但是,几周前我再次测试时,我开始遇到这个异常:System.AccessViolationException。在以下方法中发生异常:

protected virtual void GetPrintPreviewPage(object sender, GetPreviewPageEventArgs e)
{
    PrintDocument printDoc = (PrintDocument)sender;
    printDoc.SetPreviewPage(e.PageNumber, printPreviewPages[e.PageNumber - 1]); //exception occurs here
}
//e.PageNumber = 1
//sender is a Windows.UI.Xaml.Printing.PrintDocument
//printDoc is a Windows.UI.Xaml.Pringint.PrintDocument

异常详细信息:

System.AccessViolationException:'尝试读取或写入受保护的内存。这通常表明其他内存已损坏。'

我还没有在打印时找到有关此类异常的任何消息来源。如果有人知道发生了什么,我将非常感谢你的帮助。

0 个答案:

没有答案