{"record":{"id":"f2e6dffa20eaa281","repo":"dotnet/aspnetcore","slug":"the-value-of-nameof-isfixed-cannot-be-changed-d","errorCode":null,"errorMessage":"The value of {nameof(IsFixed)} cannot be changed dynamically.","messagePattern":"The value of (.+?) cannot be changed dynamically\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Components/Components/src/CascadingValue.cs","lineNumber":96,"sourceCode":"                Name = (string)parameter.Value;\n                if (string.IsNullOrEmpty(Name))\n                {\n                    throw new ArgumentException($\"The parameter '{nameof(Name)}' for component '{nameof(CascadingValue<TValue>)}' does not allow null or empty values.\");\n                }\n            }\n            else if (parameter.Name.Equals(nameof(IsFixed), StringComparison.OrdinalIgnoreCase))\n            {\n                IsFixed = (bool)parameter.Value;\n            }\n            else\n            {\n                throw new ArgumentException($\"The component '{nameof(CascadingValue<TValue>)}' does not accept a parameter with the name '{parameter.Name}'.\");\n            }\n        }\n\n        if (_hasSetParametersPreviously && IsFixed != previousFixed)\n        {\n            throw new InvalidOperationException($\"The value of {nameof(IsFixed)} cannot be changed dynamically.\");\n        }\n\n        _hasSetParametersPreviously = true;\n\n        // It's OK for the value to be null, but some \"Value\" param must be supplied\n        // because it serves no useful purpose to have a <CascadingValue> otherwise.\n        if (!hasSuppliedValue)\n        {\n            throw new ArgumentException($\"Missing required parameter '{nameof(Value)}' for component '{GetType().Name}'.\");\n        }\n\n        // Rendering is most efficient when things are queued from rootmost to leafmost.\n        // Given a components A (parent) -> B (child), you want them to be queued in order\n        // [A, B] because if you had [B, A], then the render for A might change B's params\n        // making it render again, so you'd render [B, A, B], which is wasteful.\n        // At some point we might consider making the render queue actually enforce this\n        // ordering during insertion.\n        //","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Components/src/CascadingValue.cs#L78-L114","documentation":"Thrown by CascadingValue<TValue>.SetParametersAsync when IsFixed differs from the value used in a previous parameter set. The framework caches subscriber-notification behavior based on IsFixed at first delivery, so toggling it mid-lifecycle would corrupt the subscription model. Once a CascadingValue is created with a given IsFixed, it must keep that value for all subsequent renders.","triggerScenarios":"Binding IsFixed to a value that changes between renders, e.g., <CascadingValue IsFixed=\"@_isFixedFlag\"> where _isFixedFlag toggles. The check compares against previousFixed at CascadingValue.cs:94-97.","commonSituations":"Conditionally setting IsFixed based on data that loads asynchronously; refactoring code where IsFixed was a literal and is later bound to a variable that changes.","solutions":["Decide IsFixed at component creation and keep it constant for the component's lifetime.","If you need dynamic updates, set IsFixed=false from the start (it just costs a small subscription overhead).","If the value truly never changes, set IsFixed=true once and leave it."],"exampleFix":"// before\n<CascadingValue Value=\"@_data\" IsFixed=\"@_isLoaded\">\n    <Child />\n</CascadingValue>\n@code { private bool _isLoaded = false; /* flips to true later */ }\n\n// after\n<CascadingValue Value=\"@_data\" IsFixed=\"false\">\n    <Child />\n</CascadingValue>","handlingStrategy":"validation","validationCode":"// Keep IsFixed constant across renders — verify before re-render\nif (_hasSetParametersPreviously && IsFixed != _previousFixed)\n    throw new InvalidOperationException(\"IsFixed cannot change.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use a literal or constant for IsFixed, not a dynamic binding.","Default to IsFixed=false if unsure — it's always safe, just slightly less optimal."],"tags":["blazor","cascading-value","lifecycle"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}