dotnet/wpf · error · PrintSystemException

PrintSystemException.PrintQueue.GetUninitializedProperty

Error message

PrintSystemException.PrintQueue.GetUninitializedProperty

What it means

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.

Solutions

  1. Check that the queue still exists and the user can read it before touching lazily populated properties.
  2. Call Refresh() once after constructing the queue and handle failures there rather than in deep property getters.
  3. Ensure the spooler service is running and the print server is reachable.
  4. Inspect the HResult (0x80070005 access denied, 0x800706BA RPC unavailable) to pick the right remediation.

Example fix

// before
var status = queue.QueueStatus; // may throw deep inside property getter
// after
PrintQueueStatus status;
try { status = queue.QueueStatus; }
catch (PrintSystemException ex) { throw new InvalidOperationException($"Cannot read queue '{queue.FullName}': 0x{ex.HResult:X8}", ex); }
Defensive patterns

Strategy: try-catch

Validate before calling

bool exists = server.GetPrintQueues().Any(q => q.FullName == queue.FullName);
bool spoolerUp = ServiceController.GetServices().Any(s => s.ServiceName == "Spooler" && s.Status == ServiceControllerStatus.Running);
if (!exists || !spoolerUp) throw new InvalidOperationException("Queue or spooler unavailable");

Try / catch

try { var status = queue.QueueStatus; }
catch (PrintSystemException ex) { throw new InvalidOperationException($"Cannot read properties of '{queue.FullName}': 0x{ex.HResult:X8}", ex); }

Prevention

When it happens

Trigger: 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.

Common situations: Queue deleted or renamed since construction; user lacks read permission on the shared queue; temporary spooler service stop; remote server unreachable mid-session.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/17b07fac2b49f7cc. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/PrintQueue.cpp:4236

            array<String^>^ newRefreshPropertiesFilter = gcnew array<String^>(refreshPropertiesFilter->Length + 1);

            Int32 numOfProperties = 0;

            for(numOfProperties = 0;
                numOfProperties < refreshPropertiesFilter->Length;
                numOfProperties++)
            {
                newRefreshPropertiesFilter[numOfProperties] = refreshPropertiesFilter[numOfProperties];
            }

            newRefreshPropertiesFilter[numOfProperties] = gcnew String(downLevelPropertyName->ToCharArray());
            refreshPropertiesFilter = newRefreshPropertiesFilter;

        }
    }
    catch (InternalPrintSystemException^ internalException)
    {
        throw CreatePrintSystemException(internalException->HResult, "PrintSystemException.PrintQueue.GetUninitializedProperty");
    }
    __finally
    {
        if (dataThunkObject)
        {
            delete dataThunkObject;
            dataThunkObject = nullptr;
        }
    }
}

/*++

    Routine Name:
        BuildPortNamesString

    Routine Description:

View on GitHub (pinned to 81131a70a4)