dotnet/wpf · error · ArgumentException

SR.CompoundFilePathNullEmpty

Error message

SR.CompoundFilePathNullEmpty

What it means

After stripping/validating, CompoundFileStorageReference.SetFullName converts the name to a path array; if the result is empty (null, empty string, or a string that reduces to nothing) the name cannot identify any storage. It throws ArgumentException with SR.CompoundFilePathNullEmpty for the fullName parameter.

Solutions

  1. Check String.IsNullOrEmpty(fullName) before constructing the reference and throw or substitute a valid name.
  2. Validate that the name has at least one non-separator segment after trimming.
  3. Ensure upstream parsing returns a real name or skip the item rather than creating an empty-named reference.
  4. Guard configuration/user input at the boundary with an explicit non-empty check.

Example fix

// before
var storageRef = new CompoundFileStorageReference(nameFromConfig); // may be ""
// after
if (string.IsNullOrEmpty(nameFromConfig))
    throw new ArgumentException("Storage name must be non-empty.", nameof(nameFromConfig));
var storageRef = new CompoundFileStorageReference(nameFromConfig);
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrEmpty(name) || name.Split('/').All(string.IsNullOrEmpty)) throw new ArgumentException("Name must contain at least one path segment.");

Type guard

bool IsNonEmptyPath(string name) => !string.IsNullOrEmpty(name) && ContainerUtilities.ConvertBackSlashPathToStringArrayPath(name).Length > 0;

Try / catch

try { new CompoundFileStorageReference(name); }
catch (ArgumentException) { throw new ArgumentException("Storage name required.", nameof(name)); }

Prevention

When it happens

Trigger: Constructing a CompoundFileStorageReference with fullName = "" (or a string such as separators-only input that ConvertBackSlashPathToStringArrayPath reduces to zero segments).

Common situations: Default/uninitialized string variables passed as part names, empty rows from config or data files, string.Empty produced by failed parsing/trimming upstream.

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/4df7b95c3f459421. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/CompoundFileStorageReference.cs:126

            if (fullName == null || fullName.Length == 0)
            {
                _fullName = String.Empty;
            }
            else
            {
                // fail on leading path separator to match functionality across the board
                // Although we need to do ToUpperInvariant before we do string comparison, in this case
                //  it is not necessary since PathSeparatorAsString is a path symbol
                if (fullName.StartsWith(ContainerUtilities.PathSeparatorAsString, StringComparison.Ordinal))
                    throw new ArgumentException(
                        SR.DelimiterLeading, nameof(fullName));

                _fullName = fullName;

                // ensure that the string is a legal whack-path
                string[] strings = ContainerUtilities.ConvertBackSlashPathToStringArrayPath(_fullName);
                if (strings.Length == 0)
                    throw new ArgumentException (
                        SR.CompoundFilePathNullEmpty, nameof(fullName));
            }
        }

        //------------------------------------------------------
        //
        //   Private members
        //
        //------------------------------------------------------
        // this can never be null - use String.Empty
        private String  _fullName;  // whack-path
    }
}

View on GitHub (pinned to 81131a70a4)