HandyOrg/HandyControl · error · ArgumentException
The parameter must not be the default value.
Error message
The parameter must not be the default value.
What it means
Verify.IsNotDefault throws ArgumentException when a struct parameter equals its default value (e.g. 0, Guid.Empty, default(Point)). The library uses it to reject arguments that were never explicitly initialized. It is an argument-validation guard, not a state error.
Solutions
- Initialize the struct parameter/field to a valid non-default value before calling the API.
- Check with EqualityComparer<T>.Default.Equals(value, default) before calling and fail fast with a clearer message.
- If the default is legitimately acceptable, the caller is using the wrong overload/API; switch to one that permits default values.
Example fix
// before Guid id = Guid.Empty; widget.SetId(id); // ArgumentException: The parameter must not be the default value. // after Guid id = Guid.NewGuid(); widget.SetId(id);
Defensive patterns
Strategy: validation
Validate before calling
if (EqualityComparer<T>.Default.Equals(value, default(T)))
throw new ArgumentException($"{nameof(value)} must not be the default value.", nameof(value)); Type guard
static bool IsDefault<T>(T v) where T : struct => EqualityComparer<T>.Default.Equals(v, default(T));
Try / catch
try { api.Call(value); }
catch (ArgumentException ex) when (ex.ParamName == nameof(value)) { /* handle non-default violation */ } Prevention
- Always initialize struct fields with real values (Guid.NewGuid(), explicit constructors), never rely on default(T).
- Validate struct inputs at your public boundary before passing them on.
- Watch for deserializers that leave fields at default values.
When it happens
Trigger: Calling any API that internally calls Verify.IsNotDefault(value, paramName) with the C# default of that struct type, e.g. passing Guid.Empty, 0, or default(Point) where a meaningful value is required.
Common situations: Uninitialized struct fields (a Guid or handle left at its default), deserialization that skipped a field, calling a method before assigning an ID/size/handle struct member.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- The parameter must be null.
- message
- The parameter can not be either null or empty.
- The parameter can not be either null or empty or consist…
- The property cannot be null at this time.
AI-assisted analysis of HandyOrg/HandyControl@2c0875ebd6 (2026-09-14).
Data as JSON: /api/errors/63bd26748a432f39.
Report an issue: GitHub.
Appendix: source
Thrown at src/Shared/Microsoft.Windows.Shell/Standard/Verify.cs:59
{
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())
{
throw new ArgumentException("The parameter can not be either null or empty or consist only of white space characters.", name);
}
}
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
[DebuggerStepThrough]
public static void IsNotDefault<T>(T obj, string name) where T : struct
{
T t = default(T);
if (t.Equals(obj))
{
throw new ArgumentException("The parameter must not be the default value.", name);
}
}
[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)View on GitHub (pinned to 2c0875ebd6)