{"record":{"id":"17b07fac2b49f7cc","repo":"dotnet/wpf","slug":"printsystemexception-printqueue-getuninitializedproperty","errorCode":null,"errorMessage":"PrintSystemException.PrintQueue.GetUninitializedProperty","messagePattern":"PrintSystemException\\.PrintQueue\\.GetUninitializedProperty","errorType":"exception","errorClass":"PrintSystemException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/PrintQueue.cpp","lineNumber":4236,"sourceCode":"            array<String^>^ newRefreshPropertiesFilter = gcnew array<String^>(refreshPropertiesFilter->Length + 1);\n\n            Int32 numOfProperties = 0;\n\n            for(numOfProperties = 0;\n                numOfProperties < refreshPropertiesFilter->Length;\n                numOfProperties++)\n            {\n                newRefreshPropertiesFilter[numOfProperties] = refreshPropertiesFilter[numOfProperties];\n            }\n\n            newRefreshPropertiesFilter[numOfProperties] = gcnew String(downLevelPropertyName->ToCharArray());\n            refreshPropertiesFilter = newRefreshPropertiesFilter;\n\n        }\n    }\n    catch (InternalPrintSystemException^ internalException)\n    {\n        throw CreatePrintSystemException(internalException->HResult, \"PrintSystemException.PrintQueue.GetUninitializedProperty\");\n    }\n    __finally\n    {\n        if (dataThunkObject)\n        {\n            delete dataThunkObject;\n            dataThunkObject = nullptr;\n        }\n    }\n}\n\n/*++\n\n    Routine Name:\n        BuildPortNamesString\n\n    Routine Description:\n","sourceCodeStart":4218,"sourceCodeEnd":4254,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/PrintQueue.cpp#L4218-L4254","documentation":"The property-population path used by PrintQueue when lazily fetching uninitialized properties wraps a Win32 spooler failure into a PrintSystemException tagged 'PrintSystemException.PrintQueue.GetUninitializedProperty'. It surfaces when building the data thunk object or applying the refresh-properties filter fails.","triggerScenarios":"Reading any lazily populated PrintQueue property (e.g. QueueStatus, Location, IsOffline) that triggers property refresh when OpenPrinter/GetPrinter fails — bad name, denied access, spooler down.","commonSituations":"Queue deleted or renamed since construction; user lacks read permission on the shared queue; temporary spooler service stop; remote server unreachable mid-session.","solutions":["Check that the queue still exists and the user can read it before touching lazily populated properties.","Call Refresh() once after constructing the queue and handle failures there rather than in deep property getters.","Ensure the spooler service is running and the print server is reachable.","Inspect the HResult (0x80070005 access denied, 0x800706BA RPC unavailable) to pick the right remediation."],"exampleFix":"// before\nvar status = queue.QueueStatus; // may throw deep inside property getter\n// after\nPrintQueueStatus status;\ntry { status = queue.QueueStatus; }\ncatch (PrintSystemException ex) { throw new InvalidOperationException($\"Cannot read queue '{queue.FullName}': 0x{ex.HResult:X8}\", ex); }","handlingStrategy":"try-catch","validationCode":"bool exists = server.GetPrintQueues().Any(q => q.FullName == queue.FullName);\nbool spoolerUp = ServiceController.GetServices().Any(s => s.ServiceName == \"Spooler\" && s.Status == ServiceControllerStatus.Running);\nif (!exists || !spoolerUp) throw new InvalidOperationException(\"Queue or spooler unavailable\");","typeGuard":null,"tryCatchPattern":"try { var status = queue.QueueStatus; }\ncatch (PrintSystemException ex) { throw new InvalidOperationException($\"Cannot read properties of '{queue.FullName}': 0x{ex.HResult:X8}\", ex); }","preventionTips":["Avoid holding PrintQueue instances across printer rename/delete operations.","Touch lazily-populated properties only after a successful Refresh().","Check spooler service state before reading queue properties.","Decode HResult (access denied vs RPC unavailable) to choose remediation."],"tags":["printing","wpf","win32-spooler"],"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"}