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

  1. Pass a meaningful non-empty feature ID (e.g. "DataSpace" or the transform's registered name)
  2. Trim/validate the feature-id string and reject empty values before construction
  3. 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

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


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)