Hi I'm being driven mad with a bug that i just cant reproduce on any machine i can get direct access to!
I'm just printing a visual from a WPF app. The print code is extremely basic.
- "PrinterName" is a simple string of the printer name taken directly from the printer settings.
- "usercontrol" is a basic user control with a few bits of text arranged on.
PrintDialog printDlg = new PrintDialog();
printDlg.PrintQueue = new LocalPrintServer().GetPrintQueue(PrinterName);
printDlg.PrintVisual(usercontrol, "Printout");
as noted on almost all machines this code works flawlessly HOWEVER on some machines at some random intervals it causes a hard crash outside the managed code which i cant seam to log so all i get is the event viewer crash info below (personal details removed).
One item of note, i had to build an alternative printing option (doesnt work well) for this program to work on an older instance of windows server due to printvisual using some sort of usercontrol -> XPS -> printing process and said windows server version not having XPS available. This alternative method has never seamed to fail however due to the variances on printers requires a LOT of manual caliberation per printer to ensure the printout is of suitable quality and margin so isnt really a good solution. The above print visial results in perfect printouts 100% of the time on any printer...when its not crashing the entire program!
- Faulting module name: ntdll.dll, version: 10.0.19041.1741
- Exception code: 0xc0000374 --heap corruption ?
- Fault offset: 0x00000000000ff249
- Faulting module path: C:\WINDOWS\SYSTEM32\ntdll.dll
I've refactored the printing code multiple times. The above code was my solution to this problem as I was previously generating the print queue manually instead of using the "GetPrintQueue", and so solved the issue for most users experiencing the issue for the last few months, however the above has now started crashing on (at least to my knowladge) one system!