{"record":{"id":"3a5ea5c3d3f2410c","repo":"dotnet/wpf","slug":"storyboard-beginstoryboardnamenotfound","errorCode":"Storyboard_BeginStoryboardNameNotFound","errorMessage":"SR.Format(SR.Storyboard_BeginStoryboardNameNotFound, targetName)","messagePattern":"SR\\.Format\\(SR\\.Storyboard_BeginStoryboardNameNotFound, targetName\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Media/Animation/Storyboard.cs","lineNumber":350,"sourceCode":"        {\n            namedObject = fce.FindName(targetName);\n            if( namedObject == null )\n            {\n                throw new InvalidOperationException(\n                    SR.Format(SR.Storyboard_NameNotFound, targetName, fce.GetType().ToString()));\n            }\n        }\n        else\n        {\n            throw new InvalidOperationException(\n                SR.Format(SR.Storyboard_NoNameScope, targetName));\n        }\n\n        beginStoryboard = namedObject as BeginStoryboard;\n\n        if( beginStoryboard == null )\n        {\n            throw new InvalidOperationException(SR.Format(SR.Storyboard_BeginStoryboardNameNotFound, targetName));\n        }\n\n        return beginStoryboard;\n    }\n\n    /// <summary>\n    ///     Recursively walks the clock tree and determine the target object\n    /// and property for each clock in the tree.\n    /// </summary>\n    /// <remarks>\n    ///     The currently active object and property path are passed in as parameters,\n    /// they will be used unless a target/property specification exists on\n    /// the Timeline object corresponding to the current clock.  (So that the\n    /// leaf-most reference wins.)\n    ///\n    ///     The active object and property parameters may be null if they have\n    /// never been specified.  If we reach a leaf node clock and a needed attribute\n    /// is still null, it is an error condition.  Otherwise we keep hoping they'll be found.","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Media/Animation/Storyboard.cs#L332-L368","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"<!-- before: TargetName points at the Storyboard name -->\n<BeginStoryboard x:Name=\"theBegin\">\n  <Storyboard x:Name=\"theStoryboard\">...</Storyboard>\n</BeginStoryboard>\n<!-- PauseStoryboard TargetName=\"theStoryboard\" -> throws -->\n\n<!-- after -->\n<!-- PauseStoryboard TargetName=\"theBegin\" -->","handlingStrategy":"type-guard","validationCode":"var resolved = fe.FindName(targetName);\nif (resolved is not BeginStoryboard)\n    throw new InvalidOperationException($\"'{targetName}' resolves to {resolved?.GetType().Name}, not BeginStoryboard\");","typeGuard":"resolved is BeginStoryboard beginStoryboard;","tryCatchPattern":"try { storyboard.Pause(fe); }\ncatch (InvalidOperationException ex) {\n    // check TargetName points at the BeginStoryboard, not the Storyboard/element\n}","preventionTips":["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."],"tags":["wpf","storyboard","xaml","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}