{"record":{"id":"6aef4275e968720a","repo":"dotnet/wpf","slug":"printconfig-provider-getprintcapfail","errorCode":"PrintConfig.Provider.GetPrintCapFail","errorMessage":"PrintConfig.Provider.GetPrintCapFail","messagePattern":"PrintConfig\\.Provider\\.GetPrintCapFail","errorType":"error_code","errorClass":"PrintQueueException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PTProvider.cs","lineNumber":240,"sourceCode":"                    uint hResult = UnsafeNativeMethods.PTGetPrintCapabilities(_providerHandle, printTicketStream, printCapabilitiesStream, out errorMsg);\n                    if (PTUtility.IsSuccessCode(hResult))\n                    {\n                        RewindIStream(printCapabilitiesStream);\n                        return MemoryStreamFromIStream(printCapabilitiesStream);\n                    }\n\n                    if (hResult == (uint)NativeErrorCode.E_PRINTTICKET_FORMAT)\n                    {\n                        throw new ArgumentException(String.Format(CultureInfo.CurrentCulture,\n                                      \"{0} {1} {2}\",\n                                      PrintSchemaTags.Framework.PrintTicketRoot,\n                                      PTUtility.GetTextFromResource(\"FormatException.XMLNotWellFormed\"),\n                                      errorMsg),\n                                      nameof(printTicket));\n                    }\n                    else\n                    {\n                        throw new PrintQueueException((int)hResult,\n                                                      \"PrintConfig.Provider.GetPrintCapFail\",\n                                                      _deviceName,\n                                                      errorMsg);\n                    }\n                }\n                finally\n                {\n                    DeleteIStream(ref printTicketStream);\n                }\n            }\n            finally\n            {\n                DeleteIStream(ref printCapabilitiesStream);\n            }\n        }\n\n        /// <summary>\n        /// Merges delta PrintTicket with base PrintTicket and then validates the merged PrintTicket.","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/ReachFramework/PrintConfig/PTProvider.cs#L222-L258","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nvar caps = provider.GetPrintCapabilities(printTicket); // throws on driver failure\n// after\nPrintCapabilities caps;\ntry { caps = provider.GetPrintCapabilities(printTicket); }\ncatch (PrintQueueException) { caps = defaultQueue.GetPrintCapabilities(); }","handlingStrategy":"fallback","validationCode":"// verify device is still reachable before the call\nbool online = new PrintServer().GetPrintQueue(deviceName).IsAvailable;","typeGuard":null,"tryCatchPattern":"try { caps = provider.GetPrintCapabilities(printTicket); }\ncatch (PrintQueueException ex) when (ex.Message.Contains(\"PrintConfig.Provider.GetPrintCapFail\"))\n{\n    caps = queue.DefaultPrintTicket != null ? queue.GetPrintCapabilities() : null; // managed fallback\n}","preventionTips":["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."],"tags":["wpf","printing","native-interop","printcapabilities"],"backgroundTag":"api-error-response","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}