{"record":{"id":"7285fc81d7d80532","repo":"dotnet/wpf","slug":"value-cannot-be-null-parameter-value","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'value')","messagePattern":"Value cannot be null\\. \\(Parameter 'value'\\)","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/FormatVersion.cs","lineNumber":111,"sourceCode":"\n        #region Public Properties\n\n#if !PBTCOMPILER\n        /// <summary>\n        /// reader version\n        /// </summary>\n        public VersionPair ReaderVersion\n        {\n            get\n            {\n                return _reader;\n            }\n\n            set\n            {\n                if (value == null)\n                {\n                    throw new ArgumentNullException(nameof(value));\n                }\n\n                _reader = value;\n            }\n        }\n\n        /// <summary>\n        /// writer version\n        /// </summary>\n        public VersionPair WriterVersion\n        {\n            get\n            {\n                return _writer;\n            }\n            set\n            {\n                if (value == null)","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/FormatVersion.cs#L93-L129","documentation":"ArgumentNullException from the FormatVersion.Reader property setter: assigning null to replace the reader VersionPair is rejected because a FormatVersion must always retain a valid reader version. The setter validates and then assigns to the _reader field.","triggerScenarios":"formatVersion.Reader = null; on an existing FormatVersion instance, typically in version-update or migration code.","commonSituations":"Code that clears versions before setting new ones, or data-binding/initialization paths that assign null by default.","solutions":["Assign a valid VersionPair instead of null (e.g. new VersionPair(1, 0))","Skip the assignment when the new value is null","Use the constructor to build a fresh FormatVersion rather than mutating Reader to null"],"exampleFix":"// before\nformatVersion.Reader = null; // throws ArgumentNullException\n// after\nif (newReader != null)\n    formatVersion.Reader = newReader;","handlingStrategy":"type-guard","validationCode":"if (newReader != null) formatVersion.Reader = newReader;","typeGuard":"static bool CanAssignReader(VersionPair v) => v != null;","tryCatchPattern":"try { formatVersion.Reader = value; } catch (ArgumentNullException) { /* null assignment rejected */ }","preventionTips":["Never null out Reader; build a new FormatVersion instead","Guard assignments with null checks","Treat FormatVersion properties as non-nullable invariants"],"tags":["null-argument","wpf","packaging","version"],"backgroundTag":"null-argument","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"}