2014-10-29 51 views
0

我正在尝试调试/查找有关如何诊断我正在构建的Windows应用商店应用中的打印问题的文档。我看的“如何在WinRT中/ Windows应用商店的应用打印”的几个例子,并包括错误校验码在下面的完成处理程序中的公共位:Windows应用商店 - 诊断/调试打印问题(PrintTaskCompletion.Failed)

//inside the handler passed as the second parameter into CreatePrintTask 
printTask.Completed += async (s, e) => 
{ 
    //Reset all of our internal variables (code omitted) 

    if (e.Completion == PrintTaskCompletion.Failed) 
    { 
     await Execute.OnUiThreadAsync(async() => 
     { 
      //Log Error and Show a Friendly Message to the user (code omitted) 
      /*HELP - Is there anything else in the parameters passed in to the Completed event 
       handler that can help specify the error? The only thing it has is the Completion 
       property; I can't seem to find any other useful data.*/ 

     }); 
    } 
}; 

我的代码是PrintTaskCompletion.Failed位内进入,这是很好的错误正在处理,但现在我需要知道为什么它不能尝试调试问题。我一直坚持这一段时间,并没有发现任何有用的帖子/文章/书籍说如何获得有关发生的错误的更多信息,所以我可以尝试解决这个问题。

如果需要更多的代码(为简洁起见省略了很多),请告诉我。当然,请询问任何澄清问题。

谢谢!

+0

你好,这不是一个答案,但它可能会有所帮助。我一直在看源代码,我能看到获取错误信息的唯一方法就是处理IPrintDocumentPackageStatusEvent。不幸的是,我看不到任何方式从托管打印任务注册此事件。如果您使用D2D打印,则可以在创建文档包时注册此事件。我希望这有帮助。 -詹姆士 – 2014-10-29 22:06:31

回答

0

我想清楚为什么我的错误发生了。我有一个非常微妙的错误,最终导致没有实际的内容被添加到PrintDocument.AddPages处理程序中的PrintDocumentSource,这导致了我的错误。

只要我修复了这个错误,它就开始按预期工作。

谢谢你,詹姆斯提供了一个可能的解决方案!