dotnet/wpf · error · ArgumentNullException
Value cannot be null. (Parameter 'featureId')
Error message
Value cannot be null. (Parameter 'featureId')
What it means
ArgumentNullException from the FormatVersion constructor: a FormatVersion describes one feature's writer/reader/updater versions in the compound-file DataSpace version block, and a null featureId string cannot identify the feature, so construction fails fast.
Solutions
- Pass a non-null, non-empty feature ID string (e.g. "DataSpace")
- Initialize the featureId variable before constructing FormatVersion
- When parsing files, reject or skip version records with missing feature IDs before constructing
Example fix
// before var fv = new FormatVersion(featureId, w, r, u); // featureId was null // after if (string.IsNullOrEmpty(featureId)) featureId = "DataSpace"; var fv = new FormatVersion(featureId, w, r, u);
Defensive patterns
Strategy: validation
Validate before calling
if (featureId == null) throw new ArgumentException("featureId is required");
var fv = new FormatVersion(featureId, writerVersion, readerVersion, updaterVersion); Type guard
static bool IsValidFeatureId(string s) => !string.IsNullOrEmpty(s);
Prevention
- Validate constructor arguments before building FormatVersion instances
- Initialize feature IDs from constants rather than possibly-null variables
- When parsing, reject records with missing feature IDs early
When it happens
Trigger: Calling new FormatVersion(null, writerVersion, readerVersion, updaterVersion) directly, or indirectly through code that builds version records with an uninitialized feature ID.
Common situations: Custom DataSpace/transform tooling constructing FormatVersion records; deserializing version blocks where the feature-id field was empty or missing.
Related errors
- Value cannot be null. (Parameter 'readerVersion')
- Value cannot be null. (Parameter 'updaterVersion')
- Value cannot be null. (Parameter 'value')
- Value cannot be null. (Parameter 'writerVersion')
- ' ' cannot contain the path delimiter: ' '.
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/ac2867efcb36a7de.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/FormatVersion.cs:67
: this(featureId, version, version, version)
{
}
/// <summary>
/// Constructor for FormatVersion with given featureId and reader, updater,
/// and writer version
/// </summary>
/// <param name="featureId">feature identifier</param>
/// <param name="writerVersion">Writer Version</param>
/// <param name="readerVersion">Reader Version</param>
/// <param name="updaterVersion">Updater Version</param>
public FormatVersion(String featureId,
VersionPair writerVersion,
VersionPair readerVersion,
VersionPair updaterVersion)
{
if (featureId == null)
throw new ArgumentNullException(nameof(featureId));
if (writerVersion == null)
throw new ArgumentNullException(nameof(writerVersion));
if (readerVersion == null)
throw new ArgumentNullException(nameof(readerVersion));
if (updaterVersion == null)
throw new ArgumentNullException(nameof(updaterVersion));
if (featureId.Length == 0)
{
throw new ArgumentException(SR.ZeroLengthFeatureID);
}
_featureIdentifier = featureId;
_reader = readerVersion;
_updater = updaterVersion;
_writer = writerVersion;
}
View on GitHub (pinned to 81131a70a4)