dotnet/wpf · error · ArgumentNullException

Value cannot be null.

Error message

Value cannot be null.

What it means

ContainerUtilities.CheckAgainstNull is a shared null-check helper: it throws ArgumentNullException when the supplied paramRef is null, using testStringIdentifier as the parameter name. It fires when a compound-file API (e.g. reading a length-prefixed Unicode string) receives a null argument.

Solutions

  1. Pass non-null arguments to ContainerUtilities.CheckAgainstNull call sites (e.g. the string read from the compound file)
  2. Validate data read from the compound file before passing it to helpers
  3. Guard callers such as ReadByteLengthPrefixedDWordPaddedUnicodeString against null results
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/ContainerUtilities.cs:262 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/fa43f6dbe6176a15. Report an issue: GitHub.

Appendix: source

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

                    }
                    bytesRead += padLength;
                }

                bytesRead += _int32Size; //// Size of the string length read at the beginning of this method

                return inString;
            }
        }
#endif

        /// <summary>
        /// Subset of CheckStringAgainstNullAndEmpty - and just checks against null reference.
        /// </summary>
        internal static void CheckAgainstNull(object paramRef,
            string testStringIdentifier)
        {
            if (paramRef == null)
                throw new ArgumentNullException(testStringIdentifier);
        }

#if !PBTCOMPILER
        /// <summary>
        ///     Interprets a single string by treating it as a set of names
        /// delimited by a special character.  The character is the backslash,
        /// serving the same role it has served since the original MS-DOS.
        ///     The individual names are extracted from this string and 
        /// returned as an array of string names.
        ///
        ///  string "images\button.jpg" -> string [] { "images", "button.jpg" }
        ///
        /// </summary>
        /// <param name="backSlashPath">
        ///     String path to be converted
        /// </param>
        /// <returns>
        ///     The elements of the path as a string array

View on GitHub (pinned to 81131a70a4)