{"record":{"id":"0d2d16151d3d259c","repo":"dotnet/wpf","slug":"storyboard-immutabletargetnotsupported","errorCode":"Storyboard_ImmutableTargetNotSupported","errorMessage":"SR.Format(SR.Storyboard_ImmutableTargetNotSupported, path.Path)","messagePattern":"SR\\.Format\\(SR\\.Storyboard_ImmutableTargetNotSupported, path\\.Path\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Media/Animation/Storyboard.cs","lineNumber":730,"sourceCode":"                    checkingFrozenState = false;\n                }\n            }\n            // Freezable objects (other than the one returned as the value of\n            //  the first property) must not be frozen if the first one isn't.\n            else if( checkingFrozenState )\n            {\n                intermediateFreezable = intermediateObject as Freezable;\n                if( intermediateFreezable != null && intermediateFreezable.IsFrozen )\n                {\n                    if( i > 0 )\n                    {\n                        throw new InvalidOperationException(SR.Format(SR.Storyboard_PropertyPathFrozenCheckFailed, AccessorName(path, i-1), path.Path, intermediateFreezable.GetType().ToString() ));\n                    }\n                    else\n                    {\n                        // i == 0 means the targeted object itself is a frozen Freezable.\n                        //  This need a different error message.\n                        throw new InvalidOperationException(SR.Format(SR.Storyboard_ImmutableTargetNotSupported, path.Path));\n                    }\n                }\n            }\n\n            // The last object + property pairing (the one we're actually going\n            //  to stick the clock on) has further requirements.\n            if( i == path.Length-1 )\n            {\n                DependencyObject intermediateDO = intermediateObject as DependencyObject;\n                DependencyProperty intermediateDP = intermediateProperty as DependencyProperty;\n\n                if( intermediateDO == null )\n                {\n                    Debug.Assert( i > 0, \"The caller should not have set the PropertyPath context to a non DependencyObject.\" );\n                    throw new InvalidOperationException(SR.Format(SR.Storyboard_PropertyPathMustPointToDependencyObject, AccessorName(path, i-1), path.Path));\n                }\n\n                if( intermediateDP == null )","sourceCodeStart":712,"sourceCodeEnd":748,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Media/Animation/Storyboard.cs#L712-L748","documentation":"The root target object of the animation property path itself is a frozen Freezable (path segment index 0), which cannot be animated. VerifyPathIsAnimatable throws this InvalidOperationException with the path — a distinct message from the intermediate-segment frozen error because nothing along the path can ever be mutable.","triggerScenarios":"Storyboard.TargetName (or Target) resolves to an object that has been frozen — e.g. a Freezable registered as a resource, or a storyboard applied to a shared frozen resource instance rather than a UI element.","commonSituations":"Targeting a shared frozen Brush/Geometry resource directly; freezing a Freezable then using it as the animation target via RegisterName; static resources auto-frozen in some contexts then used as animation targets.","solutions":["Target a live DependencyObject (e.g. the element), animating its property rather than the frozen object itself.","Use CloneCurrentValue to obtain a mutable copy and register/apply the animation on that copy.","Do not Freeze() objects intended as animation targets.","Move the animation to the element property that owns the frozen value.","Re-register the unfrozen instance under the same name before Begin."],"exampleFix":"// before\nvar brush = (SolidColorBrush)FindResource(\"sharedBrush\");\nstoryboard.Begin(brush); // brush is frozen\n// after\nvar brush = new SolidColorBrush(((SolidColorBrush)FindResource(\"sharedBrush\")).Color);\nelement.Fill = brush;\nstoryboard.Begin(element);","handlingStrategy":"validation","validationCode":"bool CanTarget(object o) => o is Freezable f ? !f.IsFrozen : o is DependencyObject;","typeGuard":"bool IsNotFrozenFreezable(object o) => !(o is Freezable f && f.IsFrozen);","tryCatchPattern":"try { storyboard.Begin(targetObject); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"immutable\") || ex.Message.Contains(\"frozen\"))\n{\n    // resolve to a mutable clone or re-target a live DependencyObject\n}","preventionTips":["Never register frozen Freezables as animation target names","Target elements (DependencyObjects), not resource values","Clone before animating shared/frozen resources","Add pre-Begin assertion that target is not frozen"],"tags":["wpf","freezable","storyboard","frozen"],"backgroundTag":"unsupported-operation","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"}