{"record":{"id":"7f14c80504e64410","repo":"dotnet/wpf","slug":"sr-animation-invalid-defaultvalue-destination-0-value-2-7f14c8","errorCode":null,"errorMessage":"SR.Animation_Invalid_DefaultValue (destination: {0}, value: {2})","messagePattern":"SR\\.Animation_Invalid_DefaultValue \\(destination: (.+?), value: (.+?)\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/DoubleAnimation.cs","lineNumber":324,"sourceCode":"\n                    break;\n            }\n\n            if (validateOrigin \n                && !AnimatedTypeHelpers.IsValidAnimationValueDouble(defaultOriginValue))\n            {\n                throw new InvalidOperationException(\n                    SR.Format(\n                        SR.Animation_Invalid_DefaultValue,\n                        this.GetType(),\n                        \"origin\",\n                        defaultOriginValue.ToString(CultureInfo.InvariantCulture)));\n            }\n\n            if (validateDestination \n                && !AnimatedTypeHelpers.IsValidAnimationValueDouble(defaultDestinationValue))\n            {\n                throw new InvalidOperationException(\n                    SR.Format(\n                        SR.Animation_Invalid_DefaultValue,\n                        this.GetType(),\n                        \"destination\",\n                        defaultDestinationValue.ToString(CultureInfo.InvariantCulture)));\n            }\n\n\n            if (IsCumulative)\n            {\n                double currentRepeat = (double)(animationClock.CurrentIteration - 1);\n\n                if (currentRepeat > 0.0)\n                {\n                    Double accumulator = AnimatedTypeHelpers.SubtractDouble(to, from);\n\n                    accumulated = AnimatedTypeHelpers.ScaleDouble(accumulator, currentRepeat);\n                }","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/DoubleAnimation.cs#L306-L342","documentation":"DoubleAnimation.GetCurrentValueCore throws this InvalidOperationException when the animation is asked to produce a value but the destination value to animate from/to is not a valid animation value for Double (e.g. NaN or Infinity). WPF animations require finite numeric source/destination values to interpolate. The message names the offending parameter ('destination') and the invalid value.","triggerScenarios":"Calling GetCurrentValueCore (directly or via the animation engine) with defaultDestinationValue that fails AnimatedTypeHelpers.IsValidAnimationValueDouble — typically double.NaN or double.PositiveInfinity/NegativeInfinity passed as the default destination value while validateDestination is true.","commonSituations":"Data-binding an animation To/By property to a computed value that evaluates to NaN (e.g. 0/0 from a binding or a layout measure that returned NaN width); passing NaN as a default value in custom animation code; deserializing animation markup with unset or invalid values.","solutions":["Check the value bound or passed as the animation destination; replace NaN/Infinity with a finite number before the animation runs","Validate inputs with double.IsFinite(value) (or !IsNaN && !IsInfinity) before constructing/starting the animation","If the destination comes from layout, wait for layout to complete (e.g. Loaded event) so measured sizes are actual numbers instead of NaN","Wrap animation start in a try/catch for InvalidOperationException and fall back to a static value"],"exampleFix":"// before\nvar anim = new DoubleAnimation(0, double.NaN, TimeSpan.FromSeconds(1));\n// after\nvar target = double.IsFinite(computedValue) ? computedValue : 0;\nvar anim = new DoubleAnimation(0, target, TimeSpan.FromSeconds(1));","handlingStrategy":"validation","validationCode":"if (double.IsNaN(to) || double.IsInfinity(to)) throw new ArgumentException(\"Animation destination must be finite\", nameof(to));","typeGuard":"static bool IsValidAnimationTarget(double v) => double.IsFinite(v);","tryCatchPattern":"try { animation.Begin(); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"Animation_Invalid_DefaultValue\") || ex.Message.Contains(\"destination\")) { /* log and use static value */ }","preventionTips":["Never bind animation To/From to values that can be NaN (guard 0/0 division, NaN layout sizes)","Start animations after layout completes (Loaded) so measured values are real numbers","Assert double.IsFinite on all animation endpoints in debug builds"],"tags":["wpf","animation","double","nan","invalid-value"],"backgroundTag":"invalid-argument-value","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}