dotnet/wpf · error · PrintQueueException
PrintSystemException.PrintQueue.Generic
Error message
PrintSystemException.PrintQueue.Generic
What it means
A generic PrintQueue initialization failure: when the C++/CLI PrintQueue constructor's Initialize completes but the internal catch converts any InternalPrintSystemException into CreatePrintQueueException with key PrintSystemException.PrintQueue.Generic. Any error opening or validating the printer on the spooler during queue construction surfaces here with the original HRESULT preserved.
Solutions
- Verify the printer name exists via LocalPrintServer.GetPrintQueues() before constructing the PrintQueue
- Read the HResult on the PrintSystemException to identify the underlying Win32 error (0x700 for not-found, 0x5 for access denied)
- Confirm the Print Spooler service is running and the printer is online
- Run with sufficient privileges or connect as a user with print access to the target queue
Example fix
// before
var queue = new PrintQueue(server, settings.PrinterName);
// after
var name = settings.PrinterName;
if (server.GetPrintQueues(new[] { EnumeratedPrintQueueTypes.Local, EnumeratedPrintQueueTypes.Connections })
.All(q => q.FullName != name)) throw new InvalidOperationException($"Printer '{name}' not found");
var queue = new PrintQueue(server, name); Defensive patterns
Strategy: validation
Validate before calling
var server = new LocalPrintServer();
bool exists = server.GetPrintQueues().Any(q => q.FullName == printerName);
if (!exists) throw new ArgumentException($"Printer '{printerName}' does not exist"); Type guard
static PrintQueue TryGetQueue(PrintServer s, string name) => s.GetPrintQueues().FirstOrDefault(q => q.FullName == name);
Try / catch
try { var q = new PrintQueue(server, name); }
catch (PrintSystemException ex) { throw new InvalidOperationException($"Cannot open queue '{name}': 0x{ex.HResult:X}", ex); } Prevention
- Resolve queue names from GetPrintQueues() instead of hard-coding strings
- Re-enumerate queues after driver/printer changes
- Check spooler service status before constructing queues
- Surface the preserved HResult in your own error messages
When it happens
Trigger: Constructing a PrintQueue (e.g. new PrintQueue(printServer, queueName) or via LocalPrintServer.GetPrintQueue) when the printer name is invalid, the printer was removed, access is denied, or the spooler call inside Initialize fails.
Common situations: Stale or misspelled printer names cached in application settings; printer deleted or renamed between enumeration and use; insufficient permissions to open the printer handle; Print Spooler service stopped.
Related errors
- PrintConfig.Provider.BindFail
- PrintSystemException.PrintQueue.Populate
- PrintSystemException.PrintSystemJobInfo.Create
- ArgumentException.NonNegativeValue (Parameter 'squareScale')
- ArgumentException.PositiveValue (Parameter 'value')
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/9a8ec3415540f42c.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/PrintQueue.cpp:475
printTicketManager(nullptr),
isBrowsable(true),
refreshPropertiesFilter(nullptr),
hostingPrintServer(nullptr),
fullQueueName(nullptr),
clientPrintSchemaVersion(1),
printingIsCancelled(false),
accessVerifier(nullptr),
_lockObject(gcnew Object())
{
try
{
InPartialTrust = false;
InitializeInternalCollections();
refreshPropertiesFilter = propertiesFilter;
}
catch (InternalPrintSystemException^ internalException)
{
throw CreatePrintQueueException(internalException->HResult, "PrintSystemException.PrintQueue.Generic");
}
}
/*++
Function Name:
PrintQueue
Description:
Constructor of class instance for a browsable PritnQueue
used during enumerations
Parameters:
PrintServer: The Print Server hosting the print queue
PrintQueueIndexedProperty[]: Enums of properties that the queue would be
initialized with. If someone is interested in aView on GitHub (pinned to 81131a70a4)