dotnet/wpf · error · InvalidOperationException

SR.Animation_Invalid_DefaultValue

Error message

SR.Animation_Invalid_DefaultValue (destination: {0}, value: {2})

What it means

Int64Animation.GetCurrentValueCore throws this InvalidOperationException when the default destination value is not a valid Int64 animation value, per AnimatedTypeHelpers.IsValidAnimationValueInt64. This mirrors the origin check but validates the value the animation animates toward.

Solutions

  1. Set an explicit To (and From) on the Int64Animation.
  2. Verify the target property's base value is a valid Int64 at animation start.
  3. Ensure the animation targets an Int64-typed property.
  4. Pass valid defaultDestinationValue when invoking the clock manually.

Example fix

// before
var anim = new Int64Animation { From = 0 };
// after
var anim = new Int64Animation { From = 0, To = 100, Duration = Duration.FromSeconds(1) };
Defensive patterns

Strategy: validation

Validate before calling

if (!AnimatedTypeHelpers.IsValidAnimationValueInt64(defaultDestinationValue))
    throw new InvalidOperationException("destination value is not a valid Int64 animation value");

Type guard

bool IsValidInt64Value(object v) => v is long l && AnimatedTypeHelpers.IsValidAnimationValueInt64(l);

Try / catch

try { target.BeginAnimation(prop, longAnimation); }
catch (InvalidOperationException ex) when (ex.Message.Contains("destination")) {
    // restart with an explicit To value
}

Prevention

When it happens

Trigger: Running an Int64Animation whose destination (To unset) resolves to an invalid default value; calling GetCurrentValueCore with an invalid defaultDestinationValue.

Common situations: Animations attached to properties with unset/invalid base values; misuse in custom clocks or composition scenarios.

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


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/Int64Animation.cs:324

                    break;
            }

            if (validateOrigin 
                && !AnimatedTypeHelpers.IsValidAnimationValueInt64(defaultOriginValue))
            {
                throw new InvalidOperationException(
                    SR.Format(
                        SR.Animation_Invalid_DefaultValue,
                        this.GetType(),
                        "origin",
                        defaultOriginValue.ToString(CultureInfo.InvariantCulture)));
            }

            if (validateDestination 
                && !AnimatedTypeHelpers.IsValidAnimationValueInt64(defaultDestinationValue))
            {
                throw new InvalidOperationException(
                    SR.Format(
                        SR.Animation_Invalid_DefaultValue,
                        this.GetType(),
                        "destination",
                        defaultDestinationValue.ToString(CultureInfo.InvariantCulture)));
            }


            if (IsCumulative)
            {
                double currentRepeat = (double)(animationClock.CurrentIteration - 1);

                if (currentRepeat > 0.0)
                {
                    Int64 accumulator = AnimatedTypeHelpers.SubtractInt64(to, from);

                    accumulated = AnimatedTypeHelpers.ScaleInt64(accumulator, currentRepeat);
                }

View on GitHub (pinned to 81131a70a4)