Disclosure: This issue report was prepared by OpenAI Codex, an AI coding agent, from diagnostic information and test results supplied by the application developer. The report should be reviewed by a human before submission. Customer-identifying information has intentionally been omitted.
.NET version
- Target framework:
net10.0-windows
- Process architecture: x64
- .NET runtime:
10.0.12
- CoreCLR:
10.0.1226.42308
- Application type: WPF application using
System.Drawing.Printing.PrinterSettings
Description
Reading PrinterSettings.DefaultPageSettings.PaperSize for one or more offline printer queues can terminate the entire process with native exception code 0xc0000005.
The failure cannot be caught by normal managed try/catch; the process terminates before error logging in the catch block can run.
The problem reproduces on a customer Windows system but not on the developer workstation or server. The application starts normally when printer detail reads are disabled. Isolating the queried properties showed:
- Printer enumeration succeeds.
- Reading
PrintQueue.IsOffline succeeds.
- Reading
PrinterSettings.PrinterResolutions succeeds.
- Reading
PrinterSettings.DefaultPageSettings.PaperSize causes the native crash.
- Skipping printer detail reads when
PrintQueue.IsOffline == true prevents the crash. The resulting build has been deployed to the customer and operates successfully.
This may ultimately be caused by a printer driver returning malformed DEVMODE data. Nevertheless, a public managed property getter terminating the process without a catchable managed exception is unexpected.
Minimal code path
using System.Drawing.Printing;
using System.Printing;
using var server = new LocalPrintServer();
var queues = server.GetPrintQueues(
[EnumeratedPrintQueueTypes.Local, EnumeratedPrintQueueTypes.Connections]);
foreach (var queue in queues)
{
Console.WriteLine($"{queue.FullName}: IsOffline={queue.IsOffline}");
var settings = new PrinterSettings
{
PrinterName = queue.FullName
};
// PrinterResolutions succeeds on the affected system.
var resolutions = settings.PrinterResolutions;
// For an offline queue this can terminate the process with 0xc0000005.
var paperSize = settings.DefaultPageSettings.PaperSize;
Console.WriteLine($"{paperSize.Width} x {paperSize.Height}");
}
The issue currently depends on the affected customer printer/driver configuration; a hardware-independent reproduction has not yet been produced.
Expected behavior
The getter should return the paper size or throw a managed exception describing an invalid/unavailable printer or invalid driver data. It should not terminate the process.
Actual behavior
Windows Application Error / .NET Runtime event:
Application: FiftyWorker.exe
CoreCLR Version: 10.0.1226.42308
.NET Version: 10.0.12
Description: The process was terminated due to an unhandled exception.
Stack:
at Windows.Win32.PInvoke.DocumentProperties(...)
at Windows.Win32.PInvoke.DocumentProperties(...)
at System.Drawing.Printing.PrinterSettings.GetHdevmodeInternal(Char*)
at System.Drawing.Printing.PrinterSettings.GetHdevmode()
at System.Drawing.Printing.PageSettings.get_PrinterResolution()
at FiftyWorker.Local.GetPrinterList()
at FiftyWorker.MainWindow..ctor()
at FiftyWorker.Program.Main(System.String[])
A later property-isolation test identified DefaultPageSettings.PaperSize as the crashing read. Both PageSettings.PaperSize and PageSettings.PrinterResolution use the same GetHdevmode() path.
The corresponding Application Error entry was:
Faulting module: coreclr.dll, version 10.0.1226.42308
Exception code: 0xc0000005
Fault offset: 0x00000000003596cf
Workaround
Read PrintQueue.IsOffline before creating/querying PrinterSettings, and skip DefaultPageSettings for offline queues:
if (queue.IsOffline)
{
continue;
}
var settings = new PrinterSettings { PrinterName = queue.FullName };
var paperSize = settings.DefaultPageSettings.PaperSize;
Similar issue search
No issue matching the offline-printer 0xc0000005 failure was found in dotnet/winforms using these searches:
DocumentProperties GetHdevmode
DefaultPageSettings.PaperSize AccessViolation
GetHdevmode crash
printer offline access violation
The closest result is #8812, which contains the same PaperSize -> GetHdevmode -> DocumentProperties stack but concerns missing winspool.drv on Windows Nano Server and is not a duplicate of this failure.
Additional information still needed
- Exact Windows edition, version and OS build from the affected system.
- Affected printer queue type: local, shared/network connection, redirected, or other.
- Printer model, driver name, driver provider, driver version/date, INF name and port type. Queue/server/customer names may be anonymized.
- Whether the queue was already offline when the process started.
- Whether the failure remains after restarting the Print Spooler or recreating that exact queue.
- If safely obtainable outside production: a crash dump captured for the original failing build and analyzed with native symbols.
- Result with the latest supported .NET 10 servicing runtime, if newer than
10.0.12 is available when the report is submitted.
- Whether a minimal standalone x64 console/WPF application reproduces on the affected system.
Safe collection commands for the affected machine
These commands only read system/spooler metadata. They do not query DefaultPageSettings.PaperSize and therefore do not intentionally execute the crashing code path.
Get-ComputerInfo |
Select-Object WindowsProductName, WindowsVersion, OsBuildNumber, OsArchitecture
dotnet --info
dotnet --list-runtimes
Get-CimInstance Win32_Printer |
Select-Object Name, DriverName, PortName, Network, Shared, WorkOffline,
PrinterStatus, DetectedErrorState
Get-CimInstance Win32_PrinterDriver |
Select-Object Name, Version, InfName, DriverPath, SupportedPlatform
Review and anonymize printer names, server names, port names, user names and local paths before posting the output publicly.
.NET version
net10.0-windows10.0.1210.0.1226.42308System.Drawing.Printing.PrinterSettingsDescription
Reading
PrinterSettings.DefaultPageSettings.PaperSizefor one or more offline printer queues can terminate the entire process with native exception code0xc0000005.The failure cannot be caught by normal managed
try/catch; the process terminates before error logging in the catch block can run.The problem reproduces on a customer Windows system but not on the developer workstation or server. The application starts normally when printer detail reads are disabled. Isolating the queried properties showed:
PrintQueue.IsOfflinesucceeds.PrinterSettings.PrinterResolutionssucceeds.PrinterSettings.DefaultPageSettings.PaperSizecauses the native crash.PrintQueue.IsOffline == trueprevents the crash. The resulting build has been deployed to the customer and operates successfully.This may ultimately be caused by a printer driver returning malformed
DEVMODEdata. Nevertheless, a public managed property getter terminating the process without a catchable managed exception is unexpected.Minimal code path
The issue currently depends on the affected customer printer/driver configuration; a hardware-independent reproduction has not yet been produced.
Expected behavior
The getter should return the paper size or throw a managed exception describing an invalid/unavailable printer or invalid driver data. It should not terminate the process.
Actual behavior
Windows Application Error / .NET Runtime event:
A later property-isolation test identified
DefaultPageSettings.PaperSizeas the crashing read. BothPageSettings.PaperSizeandPageSettings.PrinterResolutionuse the sameGetHdevmode()path.The corresponding Application Error entry was:
Workaround
Read
PrintQueue.IsOfflinebefore creating/queryingPrinterSettings, and skipDefaultPageSettingsfor offline queues:Similar issue search
No issue matching the offline-printer
0xc0000005failure was found indotnet/winformsusing these searches:DocumentProperties GetHdevmodeDefaultPageSettings.PaperSize AccessViolationGetHdevmode crashprinter offline access violationThe closest result is #8812, which contains the same
PaperSize -> GetHdevmode -> DocumentPropertiesstack but concerns missingwinspool.drvon Windows Nano Server and is not a duplicate of this failure.Additional information still needed
10.0.12is available when the report is submitted.Safe collection commands for the affected machine
These commands only read system/spooler metadata. They do not query
DefaultPageSettings.PaperSizeand therefore do not intentionally execute the crashing code path.Review and anonymize printer names, server names, port names, user names and local paths before posting the output publicly.