dotnet/wpf · error · PrintQueueException
PrintSystemException.PrintQueue.Populate
Error message
PrintSystemException.PrintQueue.Populate
What it means
Thrown from PrintQueue::Populate when refreshing the queue's property collections fails: the internal printer thunk call that reads spooler properties throws InternalPrintSystemException, and the code converts it to CreatePrintQueueException with key PrintSystemException.PrintQueue.Populate before disposing the thunk handler. The queue's properties could not be fetched from the spooler.
Solutions
- Recreate the PrintQueue object instead of Refreshing a long-lived one whose printer may have changed
- Catch PrintSystemException around Refresh/property access and fall back to cached values or re-enumerate
- Check printer existence and spooler health when Populate fails repeatedly
- Ensure required PropertiesFilter names are valid; an invalid filter can cause the property query to fail
Example fix
// before
queue.Refresh();
var status = queue.QueueStatus;
// after
try { queue.Refresh(); var status = queue.QueueStatus; }
catch (PrintSystemException) { queue = server.GetPrintQueue(queue.Name); /* rebuild */ } Defensive patterns
Strategy: fallback
Validate before calling
if (queue == null) return;
try { _ = queue.QueueStatus; } // probe
catch (PrintSystemException) { queue = server.GetPrintQueue(queue.Name); } Type guard
static bool QueueIsValid(PrintQueue q) { try { _ = q.QueueStatus; return true; } catch (PrintSystemException) { return false; } } Try / catch
try { queue.Refresh(); }
catch (PrintSystemException) { cached = Snapshot(queue); /* fall back to cached values */ } Prevention
- Prefer short-lived PrintQueue objects over long-cached ones
- Wrap Refresh/property access in fallback-to-cache logic
- Rebuild the queue object whenever Populate fails
- Keep the PropertiesFilter to valid property names only
When it happens
Trigger: Calling Refresh() or accessing lazily-populated PrintQueue properties (e.g. GetPrintCapabilities, QueueStatus, HostingPrintServer) when the printer handle is stale/invalid, the printer was deleted, or the spooler denies the property query.
Common situations: Long-lived PrintQueue objects used after the printer was removed/reinstalled; accessing properties of a queue on an offline print server; partial-trust apps denied property access; spooler restarted between object creation and Refresh.
Related errors
- PrintConfig.Provider.BindFail
- PrintSystemException.PrintQueue.Generic
- PrintSystemException.PrintServer.Refresh
- PrintSystemException.PrintSystemJobInfo.Create
- ArgumentException.NonNegativeValue (Parameter 'squareScale')
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/89104cbeeb74d02e.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/PrintQueue.cpp:589
// Call the thunking code to populate the required properties of the
// PrintQueue Object
//
dataThunkObject = gcnew GetDataThunkObject(this->GetType());
dataThunkObject->PopulatePrintSystemObject(printerThunkHandler,
this,
propertiesAsStrings);
//
// When an object consumer asks for a refresh on the object,
// I only refresh the properties that he already asked for and
// those are maintained in the following array
//
refreshPropertiesFilter = propertiesAsStrings;
}
catch (InternalPrintSystemException^ internalException)
{
disposePrinterThunkHandler = true;
throw CreatePrintQueueException(internalException->HResult, "PrintSystemException.PrintQueue.Populate");
}
__finally
{
if (disposePrinterThunkHandler &&
printerThunkHandler)
{
delete printerThunkHandler;
printerThunkHandler = nullptr;
}
if (dataThunkObject)
{
delete dataThunkObject;
dataThunkObject = nullptr;
}
if (printerDefaults)
{View on GitHub (pinned to 81131a70a4)