WPF Print visual ntdll.dll crash

Scott 1 Reputation point
2022-02-01T10:35:02.457+00:00

Having a strange crash on some machines using when printing via an application (WPF Windows desktop app, Win X64, Core 3.0)

I need to print a usercontrol silently (no print dialog popup) from a specified printer (currently just the printer name stored as text) I'm using the below code to do so.

var server = new PrintServer();
var queues = server.GetPrintQueues(new[] { EnumeratedPrintQueueTypes.Local });
if (queues.Any(Q => Q.FullName == ThePrinterName))
{
    printDlg.PrintQueue = queues.Where(Q => Q.FullName == StaticData.PrinterName).First();
}
printDlg.PrintVisual(TheUserControl, PrintTitle);

However on some machines (I cant reproduce it) it causes a hard application crash below the level that WPF allows capturer / logging on.

Only logs of the error I can find are in event viewer like the below which I believe point to a heap corruption which "should" be mostly impossible in managed C# code so must be something else printing wise. I think it must be something relating to print visual/the print dialogue setup as printing via other methods (like printing an image) work fine.

Any pointers would be greatly appreciated!

Faulting application name: XXXXXXXXXXX.exe, version: 1.0.0.0, time stamp: 0x5e21e4b9
Faulting module name: ntdll.dll, version: 10.0.19041.1288, time stamp: 0xa280d1d6
Exception code: 0xc0000374
Fault offset: 0x00000000000ff199
Faulting process ID: 0x8a0
Faulting application start time: 0x01d816af6938c662
Faulting application path: C:\Users\OWNER\AppData\Local\Programs\XXXXXXXXXXX\XXXXXXXXXXX.exe
Faulting module path: C:\Windows\SYSTEM32\ntdll.dll
Report ID: 7a3632ca-be4a-4515-934a-8939002284b9
Faulting package full name:
Faulting package-relative application ID:

Application: XXXXXXXXX.exe
CoreCLR Version: 4.700.20.6603
.NET Core Version: 3.0.3
Description: The process was terminated due to an internal error in the
.NET Runtime at IP XXXXXXXXX(XXXXXXXXX) with exit code c0000005.

Regards
Scott

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,710 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Hui Liu-MSFT 47,341 Reputation points Microsoft Vendor
    2022-02-02T02:33:14+00:00

    Exception code 0xc0000374 means you're facing heap corruption.

    The most common causes for this kind of error are these two:

    1. A faulty RAM module
    2. Buffer overrun, when one thread tries to read something and another thread has removed data in the meanwhile. This shouldn't happen in managed code as far as I can tell.

    You probably have to get Windows Debugging Tools to figure out what's wrong if you can't debug the application in the dev environment.


    If the response is helpful, please click "Accept Answer" and upvote it.
     Note: Please follow the steps in our [documentation][5] to enable e-mail notifications if you want to receive the related email notification for this thread. 

    [5]: https://learn.microsoft.com/en-us/answers/articles/67444/email-notifications.html

    0 comments No comments

  2. Scott 1 Reputation point
    2022-02-04T11:44:28.773+00:00

    Hi narrowed the issue down to explicitly Zebra label printers. So likely some issue between the WPF XPS printing method and the Zebra driver. I've contacted zebra for support and will update here should I recieve any relevent information.

    0 comments No comments