dotnet/wpf · error · InvalidOperationException
SR.Animation_Invalid_DefaultValue
Error message
SR.Animation_Invalid_DefaultValue
What it means
Point3DAnimation.GetCurrentValueCore throws InvalidOperationException (Animation_Invalid_DefaultValue) when the default origin value is not a valid animation value for Point3D (e.g. NaN/Infinity components or an unset Point3D) while the animation must fall back to the base value.
Solutions
- Ensure the target property holds a valid finite Point3D before the animation starts
- Set explicit From/To (or By) values on the animation so the base value isn't used
- Validate the bound value (reject NaN/Infinity) in your data layer
Example fix
// before
new Point3DAnimation { Duration = TimeSpan.FromSeconds(1) }; // relies on possibly invalid base value
// after
new Point3DAnimation(new Point3D(0,0,0), new Point3D(10,10,10), Duration.Automatic); Defensive patterns
Strategy: validation
Validate before calling
bool IsValidPoint3D(Point3D p) => !double.IsNaN(p.X) && !double.IsNaN(p.Y) && !double.IsNaN(p.Z) && !double.IsInfinity(p.X) && !double.IsInfinity(p.Y) && !double.IsInfinity(p.Z); if (!IsValidPoint3D(targetValue)) targetValue = new Point3D(0,0,0); // fix before animating
Type guard
bool IsValidAnimationValue(Point3D? p) => p.HasValue && !double.IsNaN(p.Value.X) && !double.IsInfinity(p.Value.X) && !double.IsNaN(p.Value.Y) && !double.IsInfinity(p.Value.Y) && !double.IsNaN(p.Value.Z) && !double.IsInfinity(p.Value.Z);
Try / catch
try { animation.Begin(animationTarget, true); }
catch (InvalidOperationException ex) when (ex.Message.Contains("origin")) { /* set explicit From value and retry */ } Prevention
- Initialize animated Point3D properties to valid finite values
- Prefer explicit From/To to avoid relying on the base value
- Reject NaN/Infinity at the data-binding layer
When it happens
Trigger: Animating without explicit From/To/By values so the current value is used as origin, but the target property's current Point3D is invalid (NaN, Infinity, or empty/unset).
Common situations: Target property never initialized or data-bound to NaN; corrupted transform matrices producing invalid points; animation layered on a property with unset value.
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
- SR.Animation_Invalid_DefaultValue
- SR.Animation_Invalid_DefaultValue
- SR.Animation_Invalid_DefaultValue
- SR.Animation_Invalid_DefaultValue
- SR.Animation_Invalid_DefaultValue
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/b6cfe5b3f60d37f5.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/Point3DAnimation.cs:313
if (IsAdditive)
{
foundation = defaultOriginValue;
validateOrigin = true;
}
break;
default:
Debug.Fail("Unknown animation type.");
break;
}
if (validateOrigin
&& !AnimatedTypeHelpers.IsValidAnimationValuePoint3D(defaultOriginValue))
{
throw new InvalidOperationException(
SR.Format(
SR.Animation_Invalid_DefaultValue,
this.GetType(),
"origin",
defaultOriginValue.ToString(CultureInfo.InvariantCulture)));
}
if (validateDestination
&& !AnimatedTypeHelpers.IsValidAnimationValuePoint3D(defaultDestinationValue))
{
throw new InvalidOperationException(
SR.Format(
SR.Animation_Invalid_DefaultValue,
this.GetType(),
"destination",
defaultDestinationValue.ToString(CultureInfo.InvariantCulture)));
}
View on GitHub (pinned to 81131a70a4)