`PrintQueue.AddJob`没有完成

blz*_*blz 10 .net c# printing windows-10

我尝试在某些PC上使用代码.

using (var lps = new LocalPrintServer())
using(var pqueue = lps.GetPrintQueue("PRINTER-NAME"))
{
    pqueue.AddJob("job-name", @"C:\example.xps", false, pticket);
}
Run Code Online (Sandbox Code Playgroud)

仅在一台PC上,它不起作用.应用程序冻结了AddJob方法.它在等待很长时间后甚至没有完成.没有例外.

出现此问题的PC是Windows10并应用了CreatorsUpdate.其他PC是Windows7,Windows8.1和Windows10应用的AnniversaryUpdate.

这个问题是CreatorsUpdate的错误吗?

补充:
具有CreatorsUpdate的PC可以通过此代码打印xps文件.

using (var lps = new LocalPrintServer())
using(var pqueue = lps.GetPrintQueue("PRINTER-NAME"))
using (var doc = new XpsDocument(@"C:\example.xps", System.IO.FileAccess.Read))
{
    var writer = PrintQueue.CreateXpsDocumentWriter(pqueue);
    var docSeq = doc.GetFixedDocumentSequence();
    writer.Write(doc, pticket);
}
Run Code Online (Sandbox Code Playgroud)

小智 1

我确信目标打印机驱动程序不是基于 XPS 的。我也有同样的问题。

您可以先通过以下方式检查打印机的兼容性:

LocalPrintServer server = new LocalPrintServer(PrintSystemDesiredAccess.AdministrateServer);
PrintQueue queue = server.GetPrintQueue("MyPrinterName");            
MessageBox.Show(queue.IsXpsDevice.ToString());
Run Code Online (Sandbox Code Playgroud)

如果结果是假的,那就是原因。