dotnet/wpf · error · PrintServerException
PrintSystemException.PrintServer.MajorVersionCannotChange
Error message
PrintSystemException.PrintServer.MajorVersionCannotChange
What it means
The PrintServer.MajorVersion setter only accepts a value when the MajorVersion property was internally initialized (loaded from the server). If the property was not, the setter throws PrintSystemException (ERROR_NOT_SUPPORTED) keyed 'PrintSystemException.PrintServer.MajorVersionCannotChange'. The print server schema major version is not user-modifiable.
Solutions
- Do not set MajorVersion; it is server-managed metadata — remove the assignment
- Read MajorVersion only, and if version behavior is needed, use a server that reports the desired version
- Use Refresh() first if you need the server-populated value, but still avoid writing it
Example fix
// before
server.MajorVersion = 4; // throws
// after
int v = server.MajorVersion; // read-only usage
Console.WriteLine($"Server schema version: {v}"); Defensive patterns
Strategy: validation
Validate before calling
if (propertyWriteTargetsMajorVersion) throw new InvalidOperationException("MajorVersion is read-only"); Prevention
- Treat PrintServer.MajorVersion as read-only metadata
- Never copy server version properties between PrintServer instances
- Refactor bulk property writers to exclude version fields
When it happens
Trigger: Assigning to PrintServer.MajorVersion on a PrintServer whose MajorVersion property was not internally initialized by the spooler data load.
Common situations: Code attempting to 'upgrade' a print server's schema version programmatically; copying property values from one PrintServer to another; test code mutating server metadata.
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
- PrintSystemException.PrintServer.MinorVersionCannotChange
- PrintSystemException.PrintServer.Commit
- PrintSystemException.PrintServer.Generic
- PrintSystemException.PrintServer.NameCannotChange
- PrintSystemException.PrintServer.Refresh
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/2f9e24de5fb78ec6.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/PrintServer.cpp:2019
None
--*/
void
PrintServer::MajorVersion::
set(
Int32 version
)
{
VerifyAccess();
if (PropertiesCollection->GetProperty("MajorVersion")->IsInternallyInitialized)
{
majorVersion = version;
}
else
{
throw CreatePrintServerException(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED),
"PrintSystemException.PrintServer.MajorVersionCannotChange"
);
}
}
/*++
Routine Name:
set_MinorVersion
Routine Description:
Property
Arguments:
View on GitHub (pinned to 81131a70a4)