dotnet/wpf · error · InvalidOperationException
Storyboard_BeginStoryboardNameNotFound
Storyboard_BeginStoryboardNameNotFound
Error message
SR.Format(SR.Storyboard_BeginStoryboardNameNotFound, targetName)
What it means
The TargetName WAS found in the namescope, but the resolved object is not a BeginStoryboard. ControllableStoryboardActions must reference a BeginStoryboard by its x:Name; resolving to any other object (visual element, resource, the Storyboard itself) makes the control operation impossible, so an InvalidOperationException is thrown.
Solutions
- Set the controlling action's TargetName to the x:Name of the BeginStoryboard element, not the Storyboard or a target element.
- If defined in code, register the BeginStoryboard instance with FrameworkElement.RegisterName.
- Rename conflicting names so the control TargetName is unambiguous.
Example fix
<!-- before: TargetName points at the Storyboard name --> <BeginStoryboard x:Name="theBegin"> <Storyboard x:Name="theStoryboard">...</Storyboard> </BeginStoryboard> <!-- PauseStoryboard TargetName="theStoryboard" -> throws --> <!-- after --> <!-- PauseStoryboard TargetName="theBegin" -->
Defensive patterns
Strategy: type-guard
Validate before calling
var resolved = fe.FindName(targetName);
if (resolved is not BeginStoryboard)
throw new InvalidOperationException($"'{targetName}' resolves to {resolved?.GetType().Name}, not BeginStoryboard"); Type guard
resolved is BeginStoryboard beginStoryboard;
Try / catch
try { storyboard.Pause(fe); }
catch (InvalidOperationException ex) {
// check TargetName points at the BeginStoryboard, not the Storyboard/element
} Prevention
- Point control-action TargetName only at BeginStoryboard x:Name.
- Never reuse the Storyboard's x:Name as the control TargetName.
- Rename on refactor to avoid name collisions.
When it happens
Trigger: TargetName of Pause/Resume/Stop/Seek/SkipToFill matches a registered name, but that name was registered for a different object — e.g. pointing at the Storyboard's own x:Name or at an animated element.
Common situations: Copy-paste mistakes pointing TargetName at the animated element; registering the Storyboard's x:Name and using it as the control TargetName; name collisions after refactoring.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Storyboard_TargetNameNotDependencyObject
- SR.Animation_ChildMustBeKeyFrame
- SR.Animation_ChildMustBeKeyFrame
- SR.Animation_ChildMustBeKeyFrame
- SR.Animation_ChildMustBeKeyFrame
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/3a5ea5c3d3f2410c.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Media/Animation/Storyboard.cs:350
{
namedObject = fce.FindName(targetName);
if( namedObject == null )
{
throw new InvalidOperationException(
SR.Format(SR.Storyboard_NameNotFound, targetName, fce.GetType().ToString()));
}
}
else
{
throw new InvalidOperationException(
SR.Format(SR.Storyboard_NoNameScope, targetName));
}
beginStoryboard = namedObject as BeginStoryboard;
if( beginStoryboard == null )
{
throw new InvalidOperationException(SR.Format(SR.Storyboard_BeginStoryboardNameNotFound, targetName));
}
return beginStoryboard;
}
/// <summary>
/// Recursively walks the clock tree and determine the target object
/// and property for each clock in the tree.
/// </summary>
/// <remarks>
/// The currently active object and property path are passed in as parameters,
/// they will be used unless a target/property specification exists on
/// the Timeline object corresponding to the current clock. (So that the
/// leaf-most reference wins.)
///
/// The active object and property parameters may be null if they have
/// never been specified. If we reach a leaf node clock and a needed attribute
/// is still null, it is an error condition. Otherwise we keep hoping they'll be found.View on GitHub (pinned to 81131a70a4)