dotnet/wpf · error · PrintServerException

PrintSystemException.PrintServer.MinorVersionCannotChange

Error message

PrintSystemException.PrintServer.MinorVersionCannotChange

What it means

The PrintServer.MinorVersion setter mirrors MajorVersion: it only assigns when the MinorVersion property was internally initialized from the server; otherwise it throws PrintSystemException (ERROR_NOT_SUPPORTED) keyed 'PrintSystemException.PrintServer.MinorVersionCannotChange'. Minor version is server-managed and cannot be changed by user code.

Solutions

  1. Remove any assignment to MinorVersion; treat it as read-only
  2. If version-dependent logic is required, branch on the value instead of changing it
  3. Wrap writes in try-catch only as a migration guard while removing the write

Example fix

// before
server.MinorVersion = 0; // throws
// after
if (server.MinorVersion < 3) { Console.WriteLine("Legacy server detected"); } // read-only check
Defensive patterns

Strategy: validation

Validate before calling

if (propertyWriteTargetsMinorVersion) throw new InvalidOperationException("MinorVersion is read-only");

Prevention

When it happens

Trigger: Assigning to PrintServer.MinorVersion when the property was not populated internally by the spooler (e.g. freshly constructed server object).

Common situations: Code mirroring server settings between PrintServer instances; attempting to simulate a different server version; refactoring that writes all properties.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/PrintServer.cpp:2062

    None

--*/
void
PrintServer::MinorVersion::
set(
    Int32  version
    )
{
    VerifyAccess();

    if (PropertiesCollection->GetProperty("MinorVersion")->IsInternallyInitialized)
    {
        minorVersion = version;
    }
    else
    {
        throw CreatePrintServerException(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED),
                                         "PrintSystemException.PrintServer.MinorVersionCannotChange"
                                         );

    }
}

/*++

Routine Name:

    get_RestartJobOnPoolTimeout

Routine Description:

    Property

Arguments:

View on GitHub (pinned to 81131a70a4)