{"record":{"id":"da48d3cee1cc3869","repo":"dotnet/aspnetcore","slug":"cannot-notify-about-changes-because-the-gettype","errorCode":null,"errorMessage":"Cannot notify about changes because the {GetType()} is configured as fixed.","messagePattern":"Cannot notify about changes because the (.+?) is configured as fixed\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Components/Components/src/CascadingValueSource.cs","lineNumber":89,"sourceCode":"    private CascadingValueSource(bool isFixed)\n    {\n        _isFixed = isFixed;\n\n        if (!_isFixed)\n        {\n            _subscribers = new();\n        }\n    }\n\n    /// <summary>\n    /// Notifies subscribers that the value has changed (for example, if it has been mutated).\n    /// </summary>\n    /// <returns>A <see cref=\"Task\"/> that completes when the notifications have been issued.</returns>\n    public Task NotifyChangedAsync()\n    {\n        if (_isFixed)\n        {\n            throw new InvalidOperationException($\"Cannot notify about changes because the {GetType()} is configured as fixed.\");\n        }\n\n        if (_subscribers?.Count > 0)\n        {\n            var tasks = new List<Task>();\n\n            foreach (var (dispatcher, subscribers) in _subscribers)\n            {\n                tasks.Add(dispatcher.InvokeAsync(() =>\n                {\n                    var subscribersBuffer = new ComponentStateBuffer();\n                    var subscribersCount = subscribers.Count;\n                    var subscribersCopy = subscribersCount <= ComponentStateBuffer.Capacity\n                        ? subscribersBuffer[..subscribersCount]\n                        : new ComponentState[subscribersCount];\n                    subscribers.CopyTo(subscribersCopy);\n\n                    // We iterate over a copy of the list because new subscribers might get","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/dotnet/aspnetcore/blob/3600ca084e9c8b5f4174fc5e747f4c52d2100806/src/Components/Components/src/CascadingValueSource.cs#L71-L107","documentation":"CascadingValueSource created with isFixed=true is designed to never change. Calling NotifyChangedAsync on it is a programming error because fixed sources skip subscription tracking, so there is nothing to notify.","triggerScenarios":"new CascadingValueSource<T>(value, isFixed: true) followed by a call to .NotifyChangedAsync().","commonSituations":"Refactoring a non-fixed source to fixed without removing notify calls, copying code from a dynamic source, or misunderstanding the isFixed contract.","solutions":["Create the source with isFixed: false if you need change notifications.","Remove the NotifyChangedAsync call on the fixed source.","If the value must change, replace the source instance entirely instead of notifying."],"exampleFix":"// before\nvar src = new CascadingValueSource<string>(\"v\", isFixed: true);\nawait src.NotifyChangedAsync();\n// after\nvar src = new CascadingValueSource<string>(\"v\", isFixed: false);\nsrc.Value = \"v2\";\nawait src.NotifyChangedAsync();","handlingStrategy":"validation","validationCode":"// Track whether the source is fixed and skip notify calls accordingly.\nif (!sourceIsFixed)\n{\n    await source.NotifyChangedAsync();\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Choose isFixed=false at construction if you ever intend to notify.","Encapsulate notify calls behind a helper that checks the fixed flag.","Unit-test fixed sources to ensure NotifyChangedAsync is never called on them."],"tags":["blazor","cascading-value","cascading-value-source","is-fixed"],"backgroundTag":null,"analyzedSha":"3600ca084e9c8b5f4174fc5e747f4c52d2100806","analyzedAt":"2026-08-11T16:32:30.678Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}