HandyOrg/HandyControl · error · ArgumentException

The parameter must be null.

Error message

The parameter must be null.

What it means

Verify.IsNull throws ArgumentException when a reference-type parameter is NOT null but the API requires it to be null. It is a rare inverted guard used to enforce that an argument has not been set yet or must remain unset.

Solutions

  1. Pass null instead of an object instance for this parameter.
  2. If you need the object set, use the corresponding API that validates non-null (e.g. Verify.IsNotNull paths) rather than this one.
  3. Add a caller-side check that the value is null before invoking, and otherwise skip or reset the call.

Example fix

// before
widget.Bind(existingValue); // ArgumentException: The parameter must be null.
// after
if (existingValue == null)
{
    widget.Bind(existingValue);
}
Defensive patterns

Strategy: validation

Validate before calling

if (value != null)
    throw new ArgumentException($"{nameof(value)} must be null for this call.", nameof(value));

Type guard

static bool IsNull<T>(T v) where T : class => v is null;

Try / catch

try { api.Call(value); }
catch (ArgumentException ex) when (ex.ParamName == nameof(value)) { /* handle must-be-null violation */ }

Prevention

When it happens

Trigger: Calling an API whose implementation calls Verify.IsNull(obj, paramName) while passing any non-null object reference (e.g. a pre-initialized or cached instance where the API expects null/empty).

Common situations: Passing an existing/initialized object to a setter or factory slot that must start empty; re-calling an API that only accepts null the first time; confusion between 'absent' and 'empty object' in interop code.

Related errors


AI-assisted analysis of HandyOrg/HandyControl@2c0875ebd6 (2026-09-14). Data as JSON: /api/errors/859ed0fc8375f96b. Report an issue: GitHub.

Appendix: source

Thrown at src/Shared/Microsoft.Windows.Shell/Standard/Verify.cs:79

    }

    [DebuggerStepThrough]
    [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
    public static void IsNotNull<T>(T obj, string name) where T : class
    {
        if (obj == null)
        {
            throw new ArgumentNullException(name);
        }
    }

    [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
    [DebuggerStepThrough]
    public static void IsNull<T>(T obj, string name) where T : class
    {
        if (obj != null)
        {
            throw new ArgumentException("The parameter must be null.", name);
        }
    }

    [DebuggerStepThrough]
    [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
    public static void PropertyIsNotNull<T>(T obj, string name) where T : class
    {
        if (obj == null)
        {
            throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "The property {0} cannot be null at this time.", new object[]
            {
                name
            }));
        }
    }

    [DebuggerStepThrough]
    [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]

View on GitHub (pinned to 2c0875ebd6)