dotnet/wpf · error · AnimationException
Animation_Exception
Animation_Exception
Error message
SR.Animation_Exception (Animation_Exception)
What it means
An exception escaped from the InvalidateProperty call stack while applying an animated value to the target property. AnimationStorage catches any exception and rethrows it wrapped as an AnimationException carrying the clock, property, and target, with SR.Animation_Exception as the message.
Solutions
- Inspect the InnerException to find the original failure and fix the throwing property/coercion code
- Add validation in the custom animation so invalid values never reach the property
- Wrap animation start points (BeginAnimation) in try/catch AnimationException for diagnostics
Example fix
// before
storyboard.Begin(this); // AnimationException at runtime
// after
try { storyboard.Begin(this); }
catch (AnimationException ex) { log.Error($"Animation failed on {ex.Property.Name}: {ex.InnerException}"); } Defensive patterns
Strategy: try-catch
Try / catch
try { storyboard.Begin(target); }
catch (AnimationException ex) { log.Error($"{ex.Property.Name} failed: {ex.InnerException?.Message}"); } Prevention
- Always inspect InnerException of AnimationException
- Avoid throwing from property coercion/validation callbacks during animation
- Test custom animations against target properties before shipping
When it happens
Trigger: Applying an animation whose calculated value causes the property setter/coercion/validation to throw; a clock's current-time invalidation callback failing while updating the dependency property.
Common situations: Custom animations or CoerceValueCallback/ValidateValueCallback throwing; animating properties whose setters have side effects; data-binding converters failing during animation updates.
Related errors
- Animation_AnimationTimelineTypeMismatch
- Animation_CalculatedValueIsInvalidForProperty
- Animation_ChildMustBeKeyFrame
- Animation_ChildMustBeKeyFrame
- Animation_DependencyPropertyIsNotAnimatable
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/fa74855e6d3749ba.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/AnimationStorage.cs:485
if (TraceAnimation.IsEnabled)
{
TraceAnimation.TraceActivityItem(
TraceAnimation.AnimateStorageValidationFailed,
this,
animatedValue,
target,
_dependencyProperty);
}
_hadValidationError = true;
}
}
catch (Exception e)
{
// Catch all exceptions thrown during the InvalidateProperty callstack
// and wrap them in an AnimationException
throw new AnimationException(
(AnimationClock)sender,
_dependencyProperty,
(IAnimatable)target,
SR.Format(
SR.Animation_Exception,
_dependencyProperty.Name,
target.GetType().FullName,
((AnimationClock)sender).Timeline.GetType().FullName),
e);
}
}
}
private void OnRemoveRequested(object sender, EventArgs args)
{
Debug.Assert( _animationClocks != null
&& _animationClocks.Count > 0,
"An AnimationClock no longer associated with a property should not have a RemoveRequested event handler.");View on GitHub (pinned to 81131a70a4)