Sometimes print jobs started by PrintQueueStream suffer an Exception in XpsRasterService.dll

Frequent Visitor

The .NET class PrintQueueStream lets you copy xps content directly to a destination printer queue.
This method works OK on win10.


But exactly the same code running on win11 sometimes raises an Exception, always in the same place in code:


(2ec4.11d4): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
00007ffa`8638eb49 488b1b mov rbx,qword ptr [rbx] ds:00000000`00000000=????????????????

If the target printer driver reports xps in response to a GetDeviceCaps call GETTECHNOLOGY


GETTECHNOLOGY (20) : supported
Supported :

then there's no Exception.


But if GETTECHNOLOGY returns a non-XPS value then the Exception does occur.


This means that lots of printer drivers will likely fail until XpsRasterService is fixed. Using the HP Universal PostScript driver there's an error, because it reports itself as a PostScript technology. But the generic Microsoft PS and XL drivers don't have a problem because they report themselves as xps.


Here's a link to a zipped VS sln

0 Replies