`PrintQueue.AddJob` does not end

I tried using the code on some PCs.

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

It didn’t work on just one PC. The application froze with the AddJob method. It never ended even after a long wait. There are no exceptions.

The PC where this problem occurred is Windows10 and the application CreatorsUpdate. Other PCs: Windows7, Windows8.1 and Windows10 use AnniversaryUpdate.

Is this problem a CreatorsUpdate error?

Addition:
A PC that has CreatorsUpdate can print an xps file using this code.

 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); } 
+9
c # windows-10 printing
source share
1 answer

I am sure that the target printer driver is not XPS based. I had the same problem with this.

First you can check printer compatibility via:

 LocalPrintServer server = new LocalPrintServer(PrintSystemDesiredAccess.AdministrateServer); PrintQueue queue = server.GetPrintQueue("MyPrinterName"); MessageBox.Show(queue.IsXpsDevice.ToString()); 

If the result is false, then here's why.

0
source share

All Articles