{"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/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/Components/Components/src/CascadingValue.cs#L78-L114","documentation":"CascadingValue's IsFixed parameter is captured on the first render and cannot change for the component's lifetime. IsFixed controls whether subscribers are notified of value changes, so flipping it mid-lifetime would break the notification contract and is rejected with InvalidOperationException.","triggerScenarios":"First render with IsFixed=\"false\" then a subsequent render with IsFixed=\"true\" (or vice versa). Typically happens when IsFixed is bound to a variable that changes between renders.","commonSituations":"Conditionally toggling IsFixed based on data, refactoring a non-fixed value into a fixed one without restarting the component, or a parent re-rendering with a different IsFixed value.","solutions":["Keep IsFixed constant for the lifetime of the CascadingValue instance.","Use two separate CascadingValue instances if you need both fixed and non-fixed modes.","For dynamic values, keep IsFixed=\"false\" and update the Value instead of toggling IsFixed."],"exampleFix":"// before\n<CascadingValue Value=\"@val\" IsFixed=\"@isFixedToggle\">\n// after\n<CascadingValue Value=\"@val\" IsFixed=\"false\">","handlingStrategy":"validation","validationCode":"// Treat IsFixed as a constant; do not bind it to mutable state.\n// In Razor, use a literal or a readonly field:\n<CascadingValue Value=\"@val\" IsFixed=\"false\">","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never bind IsFixed to a variable that can change between renders.","Document the intended IsFixed value near the CascadingValue usage.","Use CascadingValueSource for dynamic values rather than toggling IsFixed."],"tags":["blazor","cascading-value","rendering","is-fixed"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}