HandyOrg/HandyControl · error · ArgumentNullException
The parameter can not be either null or empty.
Error message
The parameter can not be either null or empty.
What it means
Validation helper guard: Verify.IsNeitherNullNullOrEmpty throws when the string argument it is asked to check is null, empty, or whitespace-only. It fires at argument-check time in callers (typically Getters/Setters in the Standard shell library) — the input at fault is the parameter passed to the guarded API, commonly a device/context name or resource string that was never supplied.
Solutions
- Supply a non-empty string for the parameter
- Initialize the value before the call (default or from valid config)
- Add caller-side validation with a clearer error message
- Catch ArgumentNullException/ArgumentException to surface which parameter was invalid
Example fix
// before Verify.IsNeitherNullNorEmpty(config.Name, "Name"); // throws when Name is "" // after if (string.IsNullOrEmpty(config.Name)) config.Name = "Default"; Verify.IsNeitherNullNorEmpty(config.Name, "Name");
Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(value))
throw new ArgumentException($"'{name}' must be a non-empty string.", name); Type guard
static bool IsNonEmptyString(string s) => !string.IsNullOrEmpty(s);
Try / catch
try { Verify.IsNeitherNullNorEmpty(value, name); }
catch (ArgumentNullException ex) { HandleMissing(name, ex); }
catch (ArgumentException ex) { HandleEmpty(name, ex); } Prevention
- Validate string inputs with string.IsNullOrEmpty at the API boundary
- Default empty config values to sensible constants
- Distinguish null vs empty in your own error messages
When it happens
Trigger: Calling Verify.IsNeitherNullNorEmpty(null, "name") or with "" as the value — from any API whose first act is validating a required string parameter via this helper.
Common situations: Passing unset configuration strings, empty command-line/registry values, or unassigned properties into shell/jumplist APIs.
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
- The parameter can not be either null or empty or consist…
- owner
- DoubleKeyFrameCollection
- The parameter must not be the default value.
- The parameter must be null.
AI-assisted analysis of HandyOrg/HandyControl@2c0875ebd6 (2026-09-14).
Data as JSON: /api/errors/3be6fdd8b4e36d25.
Report an issue: GitHub.
Appendix: source
Thrown at src/Shared/Microsoft.Windows.Shell/Standard/Verify.cs:29
{
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DebuggerStepThrough]
public static void IsApartmentState(ApartmentState requiredState, string message)
{
if (Thread.CurrentThread.GetApartmentState() != requiredState)
{
throw new InvalidOperationException(message);
}
}
[DebuggerStepThrough]
[SuppressMessage("Microsoft.Performance", "CA1820:TestForEmptyStringsUsingStringLength")]
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
public static void IsNeitherNullNorEmpty(string value, string name)
{
if (value == null)
{
throw new ArgumentNullException(name, "The parameter can not be either null or empty.");
}
if ("" == value)
{
throw new ArgumentException("The parameter can not be either null or empty.", name);
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[SuppressMessage("Microsoft.Performance", "CA1820:TestForEmptyStringsUsingStringLength")]
[DebuggerStepThrough]
public static void IsNeitherNullNorWhitespace(string value, string name)
{
if (value == null)
{
throw new ArgumentNullException(name, "The parameter can not be either null or empty or consist only of white space characters.");
}
if ("" == value.Trim())
{View on GitHub (pinned to 2c0875ebd6)