dotnet/wpf · error · PrintQueueException
PrintConfig.Provider.GetPrintCapFail
PrintConfig.Provider.GetPrintCapFail
Error message
PrintConfig.Provider.GetPrintCapFail
What it means
PTProvider.GetPrintCapabilities failed natively: the provider's PTGetPrintCapabilities returned an HRESULT that is neither success nor E_PRINTTICKET_FORMAT, so it throws PrintQueueException with reason PrintConfig.Provider.GetPrintCapFail and the provider's error message. This indicates the driver's print ticket provider could not produce a PrintCapabilities document.
Solutions
- Inspect the errorMsg / HRESULT in the PrintQueueException to identify the driver failure.
- Retry with a null or default PrintTicket to see if the failure is ticket-specific.
- Restart the Print Spooler service.
- Update or reinstall the printer driver.
- Fall back to PrintQueue.GetPrintCapabilities (managed path) or default capabilities when the provider fails.
Example fix
// before
var caps = provider.GetPrintCapabilities(printTicket); // throws on driver failure
// after
PrintCapabilities caps;
try { caps = provider.GetPrintCapabilities(printTicket); }
catch (PrintQueueException) { caps = defaultQueue.GetPrintCapabilities(); } Defensive patterns
Strategy: fallback
Validate before calling
// verify device is still reachable before the call bool online = new PrintServer().GetPrintQueue(deviceName).IsAvailable;
Try / catch
try { caps = provider.GetPrintCapabilities(printTicket); }
catch (PrintQueueException ex) when (ex.Message.Contains("PrintConfig.Provider.GetPrintCapFail"))
{
caps = queue.DefaultPrintTicket != null ? queue.GetPrintCapabilities() : null; // managed fallback
} Prevention
- Check queue availability (IsAvailable) before provider calls.
- Update third-party drivers that fail PTGetPrintCapabilities.
- Retry with a null/default ticket to distinguish ticket-specific from driver-wide failures.
When it happens
Trigger: Calling PTProvider.GetPrintCapabilities(printTicket) where the native call returns a generic failure HRESULT (spooler error, driver crash, invalid device state) rather than a ticket-format error.
Common situations: Faulty third-party driver plugin that fails PTGetPrintCapabilities; spooler in a bad state; device removed mid-session; passing a ticket that crashes the driver's parsing rather than being rejected as E_PRINTTICKET_FORMAT.
Related errors
- PrintConfig.Provider.BindFail
- PrintConfig.Provider.DevMode2PTFail
- PrintConfig.Provider.MergeValidateFail
- PrintConfig.Provider.PT2DevModeFail
- ArgumentException.NonNegativeValue (Parameter 'squareScale')
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/6aef4275e968720a.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PTProvider.cs:240
uint hResult = UnsafeNativeMethods.PTGetPrintCapabilities(_providerHandle, printTicketStream, printCapabilitiesStream, out errorMsg);
if (PTUtility.IsSuccessCode(hResult))
{
RewindIStream(printCapabilitiesStream);
return MemoryStreamFromIStream(printCapabilitiesStream);
}
if (hResult == (uint)NativeErrorCode.E_PRINTTICKET_FORMAT)
{
throw new ArgumentException(String.Format(CultureInfo.CurrentCulture,
"{0} {1} {2}",
PrintSchemaTags.Framework.PrintTicketRoot,
PTUtility.GetTextFromResource("FormatException.XMLNotWellFormed"),
errorMsg),
nameof(printTicket));
}
else
{
throw new PrintQueueException((int)hResult,
"PrintConfig.Provider.GetPrintCapFail",
_deviceName,
errorMsg);
}
}
finally
{
DeleteIStream(ref printTicketStream);
}
}
finally
{
DeleteIStream(ref printCapabilitiesStream);
}
}
/// <summary>
/// Merges delta PrintTicket with base PrintTicket and then validates the merged PrintTicket.View on GitHub (pinned to 81131a70a4)