dotnet/wpf · error · ArgumentException
Feature ID string cannot have zero length.
Error message
Feature ID string cannot have zero length.
What it means
ArgumentException from the FormatVersion constructor when the featureId string is non-null but zero-length. A feature identifier is the key used to match version blocks to features in the DataSpace; an empty string is not a valid identifier, so construction fails after the null checks pass.
Solutions
- Pass a meaningful non-empty feature ID (e.g. "DataSpace" or the transform's registered name)
- Trim/validate the feature-id string and reject empty values before construction
- Skip or repair malformed version records when reading files
Example fix
// before
var fv = new FormatVersion(featureId, w, r, u); // featureId == ""
// after
if (string.IsNullOrEmpty(featureId)) throw new InvalidOperationException("Feature id required");
var fv = new FormatVersion(featureId, w, r, u); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(featureId)) throw new ArgumentException("featureId must be non-empty");
var fv = new FormatVersion(featureId, writerVersion, readerVersion, updaterVersion); Type guard
static bool IsNonEmptyFeatureId(string s) => !string.IsNullOrEmpty(s);
Prevention
- Trim and check feature IDs after parsing or user input
- Reject empty feature IDs at the file-reading boundary
- Use named constants for known feature IDs (e.g. "DataSpace")
When it happens
Trigger: new FormatVersion("", writerVersion, readerVersion, updaterVersion) — e.g. a parsed file yielded an empty feature-id field or a string was trimmed to empty.
Common situations: Reading malformed compound files whose version stream contains blank feature IDs; building version blocks from user-supplied or config-driven feature names.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- ' ' ID is not a valid XSD ID.
- CompoundFile path must be non-empty.
- Object identifiers must be unique within the same signature.
- Specified object ID conflicts with predefined Package…
- Specified part to sign does not exist.
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/6936da9605357d23.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/System/IO/Packaging/CompoundFile/FormatVersion.cs:77
/// <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;
}
#endregion Constructors
//------------------------------------------------------
//
// Public Properties
//
//------------------------------------------------------
#region Public Properties
View on GitHub (pinned to 81131a70a4)