dotnet/wpf · error · InvalidOperationException
SR.Format(SR.ValidationRule_UnknownStep, validationStep…
Error message
SR.Format(SR.ValidationRule_UnknownStep, validationStep, bindingGroup)
What it means
In BindingExpression.ValidateWithoutUpdate/Validate flow, the validationStep parameter selects which value object is handed to the rule (proposed values, the expression itself, etc.); the default branch throws this InvalidOperationException for any step outside the known set. Like error 2478, a closed-enum guard indicating corrupted or unsupported ValidationStep input.
Solutions
- Pass only valid ValidationStep values when invoking validation
- Fix enum deserialization/persistence so ValidationStep never exceeds the defined range
- Update custom binding subclasses to map steps correctly before calling Validate
Example fix
// before expr.ValidateWithoutUpdate((ValidationStep)42, bindingGroup); // throws // after expr.ValidateWithoutUpdate(ValidationStep.UpdatedValue, bindingGroup);
Defensive patterns
Strategy: validation
Validate before calling
if (!Enum.IsDefined(typeof(ValidationStep), validationStep)) throw new InvalidOperationException("Unknown ValidationStep"); Type guard
static bool IsSupportedStep(ValidationStep s) => Enum.IsDefined(typeof(ValidationStep), s);
Try / catch
try { Validate(value, validationStep); } catch (InvalidOperationException ex) when (ex.Message.Contains("ValidationStep")) { /* normalize step and retry */ } Prevention
- Pass only closed-set ValidationStep values in custom binding internals
- Guard persisted/deserialized ValidationStep values
- Map custom steps onto the four standard ValidationStep members before calling engine APIs
When it happens
Trigger: Calling the internal validation path with a validationStep value not in RawProposedValue/ConvertedProposedValue/UpdatedValue/CommittedValue — via invalid enum casts, corrupted deserialized values, or custom BindingExpressionBase subclasses passing wrong steps.
Common situations: Custom binding-group/expression extensions (e.g. bespoke BindingGroup implementations) passing unexpected steps; enum deserialized from bad persisted state; framework version drift between rule and engine.
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
- SR.Format(SR.ValidationRule_UnknownStep…
- ArgumentNullException(nameof(value))
- FileAccess value is not valid.
- Invalid priority value.
- InvalidEnumArgumentException("key", (int)key, typeof(Key))
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/f0292a8dbc1e4da7.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Data/BindingExpression.cs:2105
{
if (!NeedsValidation)
return true;
object value;
switch (validationStep)
{
case ValidationStep.RawProposedValue:
value = GetRawProposedValue();
break;
case ValidationStep.ConvertedProposedValue:
value = bindingGroup.GetValue(this);
break;
case ValidationStep.UpdatedValue:
case ValidationStep.CommittedValue:
value = this;
break;
default:
throw new InvalidOperationException(SR.Format(SR.ValidationRule_UnknownStep, validationStep, bindingGroup));
}
return Validate(value, validationStep);
}
/// <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)
{
Debug.Assert(NeedsValidation, "check NeedsValidation before calling this");
values = null;
// validate raw proposed value
object rawValue = GetRawProposedValue();
bool isValid = Validate(rawValue, ValidationStep.RawProposedValue);View on GitHub (pinned to 81131a70a4)