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

  1. Inspect the errorMsg / HRESULT in the PrintQueueException to identify the driver failure.
  2. Retry with a null or default PrintTicket to see if the failure is ticket-specific.
  3. Restart the Print Spooler service.
  4. Update or reinstall the printer driver.
  5. 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

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


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)