stride3d/stride · error · ArgumentException
cannot be equal to .
Error message
{paramName} cannot be equal to {value}. What it means
ArgumentCheck.NotEquals<T> throws ArgumentException when the variable equals the forbidden value under EqualityComparer<T>.Default. It is a guard against assigning placeholder/sentinel values (e.g. default(T), null, or a specific disallowed constant) to a parameter.
Solutions
- Ensure the variable holds a real value different from the forbidden one before the call
- If variable is an identifier, confirm it was assigned after creation/persistence rather than left at default
- Check the equality semantics: if a custom Equals makes them 'equal' unexpectedly, fix the type's Equals/GetHashCode
- If equality with that value is actually acceptable, remove the NotEquals guard or pass the correct parameter
Example fix
// before
var id = Guid.Empty;
ArgumentCheck.NotEquals(id, Guid.Empty, nameof(id));
// after
var id = entity?.Id ?? throw new InvalidOperationException("Entity must be persisted first");
ArgumentCheck.NotEquals(id, Guid.Empty, nameof(id)); Defensive patterns
Strategy: validation
Validate before calling
if (EqualityComparer<T>.Default.Equals(value, forbidden))
throw new ArgumentException($"{nameof(value)} must not be {forbidden}", nameof(value)); Try / catch
try { NotEquals(id, Guid.Empty, nameof(id)); }
catch (ArgumentException ex) when (ex.ParamName == nameof(id))
{
// assign a real id or abort the operation
} Prevention
- Never persist or forward default(T) identifiers; assign ids at creation
- Check sentinel values (Guid.Empty, 0) right after deserialization
- Implement Equals/GetHashCode correctly on custom types used with NotEquals
When it happens
Trigger: Calling ArgumentCheck.NotEquals(variable, value, variableName) where variable compares equal to value, e.g. passing default(Guid) (Guid.Empty), 0, or null for a reference-type T to a parameter that forbids exactly that value.
Common situations: Passing an uninitialized identifier (Guid.Empty, 0) because an entity was never persisted; a struct field left at default(T); a deserialized object whose id defaulted to the disallowed sentinel.
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
- can't be an empty string.
- can't be null, empty, or consist only of whitespace…
- cannot be empty.
- ArgumentNullException: paramName
- Custom strides is not supported with packed PixelFormats
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/69836e9bb640a6f8.
Report an issue: GitHub.
Appendix: source
Thrown at sources/editor/Stride.Core.Assets.Editor/ArgumentCheck.cs:158
/// <summary>
/// Checks whether the <paramref name="variable"/> is different from <paramref name="value"/>.
/// Otherwise throws an exception.
/// </summary>
/// <typeparam name="T">The type of the <paramref name="variable"/>.</typeparam>
/// <param name="variable">The value to check.</param>
/// <param name="value">The value to compare to for inequality.</param>
/// <param name="variableName">The name of the variable being checked.</param>
/// <exception cref="ArgumentException">
/// <paramref name="variable"/> is equal to the <paramref name="value"/>.
/// </exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void NotEquals<T>(T variable, T value, string variableName)
{
var paramName = variableName ?? "The variable";
if (EqualityComparer<T>.Default.Equals(variable, value))
{
throw new ArgumentException($"{paramName} cannot be equal to {value}.");
}
}
/// <summary>
/// Checks wether the <paramref name="variable"/> is not <see langword="null"/>.
/// Otherwise throws an exception.
/// </summary>
/// <param name="variable">The value to check.</param>
/// <param name="variableName">The name of the variable being checked.</param>
/// <exception cref="ArgumentNullException">
/// The <paramref name="variable"/> cannot be <see langword="null"/>.
/// </exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void NotNull(object variable, string variableName)
{
var paramName = variableName ?? "The variable";
if (null == variable)
{View on GitHub (pinned to 96fad776d2)