{"record":{"id":"cd16525e4dcc2b45","repo":"dotnet/wpf","slug":"invalidoperationexception-no-message","errorCode":null,"errorMessage":"InvalidOperationException (no message)","messagePattern":"InvalidOperationException \\(no message\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/VisualStateManager.cs","lineNumber":192,"sourceCode":"                    group = g;\n                    state = s;\n                    return true;\n                }\n            }\n\n            group = null;\n            state = null;\n            return false;\n        }\n\n        private static bool GoToStateInternal(FrameworkElement control, FrameworkElement stateGroupsRoot, VisualStateGroup group, VisualState state, bool useTransitions)\n        {\n            ArgumentNullException.ThrowIfNull(stateGroupsRoot);\n            ArgumentNullException.ThrowIfNull(state);\n\n            if (group == null)\n            {\n                throw new InvalidOperationException();\n            }\n\n            VisualState lastState = group.CurrentState;\n            if (lastState == state)\n            {\n                return true;\n            }\n\n            // Get the transition Storyboard. Even if there are no transitions specified, there might\n            // be properties that we're rolling back to their default values.\n            VisualTransition transition = useTransitions ? VisualStateManager.GetTransition(stateGroupsRoot, group, lastState, state) : null;\n\n            // Generate dynamicTransition Storyboard\n            Storyboard dynamicTransition = GenerateDynamicTransitionAnimations(stateGroupsRoot, group, state, transition);\n\n            // If the transition is null, then we want to instantly snap. The dynamicTransition will\n            // consist of everything that is being moved back to the default state.\n            // If the transition.Duration and explicit storyboard duration is zero, then we want both the dynamic ","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/VisualStateManager.cs#L174-L210","documentation":"VisualStateManager.GoToStateInternal transitions a control to a named VisualState. If the supplied state belongs to no VisualStateGroup known to this VisualStateManager (group == null), the framework throws a bare InvalidOperationException indicating an internal lookup failure - the state's group could not be resolved for the given stateGroupsRoot. It signals the state/group topology does not match what the caller passed.","triggerScenarios":"Calling VisualStateManager.GoToState(control, stateName, useTransitions) where the state name exists but its VisualStateGroup cannot be located on the control's template root, or calling GoToStateCore with mismatched group/state arguments.","commonSituations":"Template VSM tree out of sync with the code-behind state names after renaming states; control template lacks the expected VisualStateGroup; custom controls calling GoToState with states not defined in the template's VisualStateManager.VisualStateGroups.","solutions":["Verify the control template defines a VisualStateManager.VisualStateGroups element containing the state group and state name used in GoToState","Ensure state names in code exactly match XAML state names (case-sensitive)","If GoToState returned false previously, check the template was applied (ApplyTemplate) before transitioning","Restructure so states live inside proper VisualStateGroup containers"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"var groups = VisualStateManager.GetVisualStateGroups(root);\nif (!groups.Any(g => g.States.Any(s => s.Name == stateName))) return false;","typeGuard":"bool StateExists(FrameworkElement root, string name) =>\n    VisualStateManager.GetVisualStateGroups(root)?.OfType<VisualStateGroup>()\n        .Any(g => g.States.OfType<VisualState>().Any(s => s.Name == name)) == true;","tryCatchPattern":"try { VisualStateManager.GoToState(control, stateName, true); } catch (InvalidOperationException) { /* template not applied or state missing; defer until loaded */ }","preventionTips":["Define all states inside VisualStateGroup containers in the template","Call GoToState only after the template is applied (OnApplyTemplate/Loaded)","Keep state names in code and XAML in sync"],"tags":["wpf","visualstatemanager","state","template"],"backgroundTag":"invalid-state-transition","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"}