{"record":{"id":"5bd8f4dc48c80ece","repo":"dotnet/wpf","slug":"storyboard-unabletofreeze","errorCode":"Storyboard_UnableToFreeze","errorMessage":"SR.Storyboard_UnableToFreeze","messagePattern":"SR\\.Storyboard_UnableToFreeze","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Media/Animation/BeginStoryboard.cs","lineNumber":146,"sourceCode":"            // Gets our Storyboard value.  This value may have come from a\n            //  ResourceReferenceExpression or might have been a deferred\n            //  reference that has since been realized.\n            Storyboard snapshot = GetValue(StoryboardProperty) as Storyboard;\n\n            if( snapshot == null )\n            {\n                // This is the same error thrown by Begin if the Storyboard\n                //  property couldn't be resolved at Begin time.  Since we're\n                //  not allowing changes after this point, lack of resolution\n                //  here means the same thing.\n                throw new InvalidOperationException(SR.Storyboard_StoryboardReferenceRequired);\n            }\n            \n            // We're planning to break our thread affinity - we also need to\n            //  make sure the Storyboard can also be used accross threads.\n            if(!snapshot.CanFreeze)\n            {\n                throw new InvalidOperationException(SR.Storyboard_UnableToFreeze);\n            }\n            if(!snapshot.IsFrozen)\n            {\n                snapshot.Freeze();\n            }\n\n            // Promote that snapshot into a local value.  This is a no-op if it\n            //  was a deferred reference or local Storyboard, but if it came from a \n            //  ResourceReferenceExpression it will replace the Expression object\n            //  with a snapshot of its current value.\n            Storyboard = snapshot;\n        }\n        else\n        {\n            ; // base.Seal() will throw exception for us if already sealed.\n        }\n\n        base.Seal();        ","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Media/Animation/BeginStoryboard.cs#L128-L164","documentation":"BeginStoryboard.Seal throws InvalidOperationException (SR.Storyboard_UnableToFreeze) when the resolved Storyboard snapshot cannot be frozen. Sealing breaks thread affinity by freezing the storyboard; a storyboard holding unfreezable state (e.g. bound or dynamic values) prevents that.","triggerScenarios":"Sealing a BeginStoryboard whose Storyboard's CanFreeze returns false - typically because the storyboard's animations contain data bindings, DynamicResource references, or other expressions that block freezing.","commonSituations":"Storyboards with animated property values set via {Binding} or {DynamicResource} inside styles/templates, or animations using non-frozen brushes/gradients with mutable state.","solutions":["Remove data bindings and DynamicResource references from the storyboard's animation values; use static values.","Freeze any brushes, transforms, or keyframes used by the animations so the whole storyboard becomes freezable.","Replace bound values with StaticResource references to pre-declared frozen resources."],"exampleFix":"// before\n<DoubleAnimation To=\"{Binding MaxOpacity}\" Storyboard.TargetProperty=\"Opacity\"/>\n// after\n<DoubleAnimation To=\"1.0\" Storyboard.TargetProperty=\"Opacity\"/>","handlingStrategy":"validation","validationCode":"if (storyboard.CanFreeze)\n    storyboard.Freeze();\nelse\n    throw new InvalidOperationException(\"Storyboard contains unfreezable values (bindings/dynamic resources)\");","typeGuard":null,"tryCatchPattern":"try { template.Seal(); }\ncatch (InvalidOperationException ex) { /* storyboard not freezable; strip bindings */ }","preventionTips":["Avoid {Binding} and {DynamicResource} inside storyboard animation values","Freeze brushes, transforms, and keyframes used by animations","Prefer static values or frozen StaticResource references in templates"],"tags":["wpf","animation","freezable","csharp"],"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-21T21:30:21.729Z"}