{"record":{"id":"955abe3dcd129f46","repo":"dotnet/wpf","slug":"value-cannot-be-null-parameter-readerversion","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'readerVersion')","messagePattern":"Value cannot be null\\. \\(Parameter 'readerVersion'\\)","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/FormatVersion.cs","lineNumber":71,"sourceCode":"        /// <summary>\n        /// Constructor for FormatVersion with given featureId and reader, updater,\n        /// and writer version\n        /// </summary>\n        /// <param name=\"featureId\">feature identifier</param>\n        /// <param name=\"writerVersion\">Writer Version</param>\n        /// <param name=\"readerVersion\">Reader Version</param>\n        /// <param name=\"updaterVersion\">Updater Version</param>\n        public FormatVersion(String featureId,\n                                VersionPair writerVersion,\n                                VersionPair readerVersion,\n                                VersionPair updaterVersion)\n        {\n            if (featureId == null)\n                throw new ArgumentNullException(nameof(featureId));\n            if (writerVersion == null)\n                throw new ArgumentNullException(nameof(writerVersion));\n            if (readerVersion == null)\n                throw new ArgumentNullException(nameof(readerVersion));\n            if (updaterVersion == null)\n                throw new ArgumentNullException(nameof(updaterVersion));\n\n            if (featureId.Length == 0)\n            {\n                throw new ArgumentException(SR.ZeroLengthFeatureID);\n            }\n\n            _featureIdentifier = featureId;\n            _reader = readerVersion;\n            _updater = updaterVersion;\n            _writer = writerVersion;\n        }\n\n        #endregion Constructors\n\n        //------------------------------------------------------\n        //","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/FormatVersion.cs#L53-L89","documentation":"ArgumentNullException from the FormatVersion constructor when readerVersion is null. The reader version records the minimum version able to read the feature's data and is required for the DataSpace version block to be well-formed.","triggerScenarios":"new FormatVersion(featureId, writerVersion, null, updaterVersion) — passing a null reader VersionPair.","commonSituations":"Custom transform/version-block construction where the reader version was omitted; copying constructor calls and missing one of the three version arguments.","solutions":["Pass a valid VersionPair for readerVersion (e.g. new VersionPair(1, 0))","Ensure all three VersionPair arguments are initialized before construction","Add null checks on parsed values before wrapping them in FormatVersion"],"exampleFix":"// before\nvar fv = new FormatVersion(id, writer, null, updater);\n// after\nvar reader = new VersionPair(1, 0);\nvar fv = new FormatVersion(id, writer, reader, updater);","handlingStrategy":"validation","validationCode":"if (readerVersion == null) throw new ArgumentException(\"readerVersion is required\");\nvar fv = new FormatVersion(featureId, writerVersion, readerVersion, updaterVersion);","typeGuard":"static bool IsValidVersion(VersionPair v) => v != null;","tryCatchPattern":null,"preventionTips":["Initialize reader version alongside writer/updater versions","Use defaults (1.0) when the value is unknown","Null-check parsed version values before constructing FormatVersion"],"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"}