{"record":{"id":"3ca8d02ecc4ae46e","repo":"dotnet/wpf","slug":"printsystemexception-printqueue-xpsdevicequery","errorCode":null,"errorMessage":"PrintSystemException.PrintQueue.XpsDeviceQuery","messagePattern":"PrintSystemException\\.PrintQueue\\.XpsDeviceQuery","errorType":"exception","errorClass":"PrintQueueException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/PrintQueue.cpp","lineNumber":2913,"sourceCode":"    void\n    )\n{\n    Boolean printerIsXpsDevice = false;\n\n    try\n    {\n        if (isBrowsable)\n        {\n            ActivateBrowsableQueue();\n            isBrowsable = false;\n        }\n\n        printerIsXpsDevice = printerThunkHandler->ThunkIsMetroDriverEnabled();\n\n    }\n    catch (InternalPrintSystemException^ internalException)\n    {\n        throw CreatePrintQueueException(internalException->HResult,\n                                        \"PrintSystemException.PrintQueue.XpsDeviceQuery\");\n    }\n    return printerIsXpsDevice;\n}\n\nBoolean\nPrintQueue::IsXpsDevice::\nget(\n    void\n    )\n{\n    VerifyAccess();\n\n    if (!PropertiesCollection->GetProperty(\"IsXpsEnabled\")->IsInitialized)\n    {\n        isXpsDevice = this->GetIsXpsDevice();\n        PropertiesCollection->GetProperty(\"IsXpsEnabled\")->IsInternallyInitialized = true;\n        PropertiesCollection->GetProperty(\"IsXpsEnabled\")->Value = isXpsDevice;","sourceCodeStart":2895,"sourceCodeEnd":2931,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/PrintQueue.cpp#L2895-L2931","documentation":"PrintQueue.GetIsXpsDevice wraps a failure from ThunkIsMetroDriverEnabled (Win32 driver/DEVMODE query) into a PrintSystemException tagged 'PrintSystemException.PrintQueue.XpsDeviceQuery'. This check determines whether the queue's driver is XPS-based; the HResult carries the native error.","triggerScenarios":"Accessing queue.IsXpsDevice (or APIs that query it like GetPrintCapabilities on a partially initialized queue) when the driver configuration query fails — driver missing/corrupt, DEVMODE unreadable, or the queue handle could not be opened.","commonSituations":"Legacy v3 driver uninstalled or upgraded concurrently; printer name resolved but driver package broken; remote queue on a server with different driver architecture (x64 vs ARM64).","solutions":["Reinstall/repair the printer driver on the host and confirm DriverName resolves in PrintServer.GetPrintQueues().","Call queue.Refresh() before querying IsXpsDevice so the queue handle is initialized.","Verify the print server's driver architecture matches the client process.","Catch the exception and treat the queue as non-XPS if your workflow can fall back to GDI printing."],"exampleFix":"// before\nbool isXps = queue.IsXpsDevice;\n// after\nbool isXps;\ntry { isXps = queue.IsXpsDevice; }\ncatch (PrintSystemException) { isXps = false; } // fall back to non-XPS/GDI path\n","handlingStrategy":"fallback","validationCode":"bool driverOk = !string.IsNullOrEmpty(queue.DriverName);\nif (!driverOk) throw new InvalidOperationException(\"Queue has no usable driver; IsXpsDevice query would fail\");","typeGuard":null,"tryCatchPattern":"bool isXps;\ntry { isXps = queue.IsXpsDevice; }\ncatch (PrintSystemException) { isXps = false; } // degrade to non-XPS path\n","preventionTips":["Call Refresh() to initialize the queue before querying driver-derived properties.","Repair/reinstall broken driver packages on the print server.","Match client process architecture to the server's driver architecture.","Design printing code to tolerate unknown XPS capability (GDI fallback)."],"tags":["printing","wpf","driver"],"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-21T21:30:21.729Z"}