dotnet/wpf · error · InvalidOperationException

SR.ValidationRule_UnknownStep (formatted with…

Error message

SR.ValidationRule_UnknownStep (formatted with validationStep, bindingGroup)

What it means

During validation (ValidateWithoutUpdate / validation evaluation), MultiBindingExpression throws InvalidOperationException when the ValidationStep has an unrecognized value not covered by RawProposedValue, ConvertedProposedValue, UpdatedValue, or CommittedValue. This is effectively an internal invariant check against a corrupted or future ValidationStep enum value.

Solutions

  1. Set ValidationRule.ValidationStep to a valid enum member (RawProposedValue, ConvertedProposedValue, UpdatedValue, or CommittedValue)
  2. Remove or fix rules with invalid ValidationStep values before the binding evaluates
  3. Verify assembly/runtime versions match so the ValidationStep enum is consistent

Example fix

// before
rule.ValidationStep = (ValidationStep)99;
// after
rule.ValidationStep = ValidationStep.ConvertedProposedValue;
Defensive patterns

Strategy: validation

Validate before calling

bool knownStep = step is ValidationStep.RawProposedValue or ValidationStep.ConvertedProposedValue or ValidationStep.UpdatedValue or ValidationStep.CommittedValue;

Type guard

bool IsValidStep(ValidationStep s) => s is ValidationStep.RawProposedValue or ValidationStep.ConvertedProposedValue or ValidationStep.UpdatedValue or ValidationStep.CommittedValue;

Try / catch

try { rule.Validate(value, culture); } catch (InvalidOperationException) { /* unknown ValidationStep; fix rule configuration */ }

Prevention

When it happens

Trigger: A ValidationRule whose ValidationStep property was set to an out-of-range/unknown value (e.g. invalid cast, hand-built enum value) and then evaluated against the MultiBindingExpression/bindingGroup.

Common situations: Manually constructing ValidationStep values via unsafe casts; deserialization producing a value not present in the current enum; framework-version mismatch where new enum members are evaluated by older code paths.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/MultiBindingExpression.cs:849

    /// <summary>
    /// Run validation rules for the given step, and inform the binding group
    /// <summary>
    internal override bool CheckValidationRules(BindingGroup bindingGroup, ValidationStep validationStep)
    {
        if (!NeedsValidation)
            return true;

        object value;
        switch (validationStep)
        {
            case ValidationStep.RawProposedValue:
            case ValidationStep.ConvertedProposedValue:
            case ValidationStep.UpdatedValue:
            case ValidationStep.CommittedValue:
                value = bindingGroup.GetValue(this);
                break;
            default:
                throw new InvalidOperationException(SR.Format(SR.ValidationRule_UnknownStep, validationStep, bindingGroup));
        }

        bool result = Validate(value, validationStep);

        if (result && validationStep == ValidationStep.CommittedValue)
        {
            NeedsValidation = false;
        }

        return result;
    }

    /// <summary>
    /// Get the proposed value(s) that would be written to the source(s), applying
    /// conversion and checking UI-side validation rules.
    /// </summary>
    internal override bool ValidateAndConvertProposedValue(out Collection<ProposedValue> values)
    {

View on GitHub (pinned to 81131a70a4)