{"record":{"id":"2f9e24de5fb78ec6","repo":"dotnet/wpf","slug":"printsystemexception-printserver-majorversioncannotchange","errorCode":null,"errorMessage":"PrintSystemException.PrintServer.MajorVersionCannotChange","messagePattern":"PrintSystemException\\.PrintServer\\.MajorVersionCannotChange","errorType":"exception","errorClass":"PrintServerException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/PrintServer.cpp","lineNumber":2019,"sourceCode":"\n    None\n\n--*/\nvoid\nPrintServer::MajorVersion::\nset(\n    Int32  version\n    )\n{\n    VerifyAccess();\n\n    if (PropertiesCollection->GetProperty(\"MajorVersion\")->IsInternallyInitialized)\n    {\n        majorVersion = version;\n    }\n    else\n    {\n        throw CreatePrintServerException(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED),\n                                         \"PrintSystemException.PrintServer.MajorVersionCannotChange\"\n                                         );\n\n    }\n}\n\n/*++\n\nRoutine Name:\n\n    set_MinorVersion\n\nRoutine Description:\n\n    Property\n\nArguments:\n","sourceCodeStart":2001,"sourceCodeEnd":2037,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Printing/CPP/src/PrintServer.cpp#L2001-L2037","documentation":"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.","triggerScenarios":"Assigning to PrintServer.MajorVersion on a PrintServer whose MajorVersion property was not internally initialized by the spooler data load.","commonSituations":"Code attempting to 'upgrade' a print server's schema version programmatically; copying property values from one PrintServer to another; test code mutating server metadata.","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"],"exampleFix":"// before\nserver.MajorVersion = 4; // throws\n// after\nint v = server.MajorVersion; // read-only usage\nConsole.WriteLine($\"Server schema version: {v}\");","handlingStrategy":"validation","validationCode":"if (propertyWriteTargetsMajorVersion) throw new InvalidOperationException(\"MajorVersion is read-only\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat PrintServer.MajorVersion as read-only metadata","Never copy server version properties between PrintServer instances","Refactor bulk property writers to exclude version fields"],"tags":["printing","print-server","unsupported-operation","version"],"backgroundTag":"unsupported-operation","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"}