{"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/294cab2f9b2e03af6b953820c7ab497c3c8b7ad9/src/Components/Components/src/CascadingValueSource.cs#L71-L107","documentation":"Thrown by CascadingValueSource<TValue>.NotifyChangedAsync when the source was constructed with isFixed=true. A fixed cascading value is an optimization that skips subscriber registration entirely, so there are no subscribers to notify. Calling NotifyChangedAsync on a fixed source is a logic error — the value was declared immutable.","triggerScenarios":"Calling NotifyChangedAsync() or NotifyChangedAsync(newValue) on a CascadingValueSource that was created with isFixed:true. The guard is at CascadingValueSource.cs:87-90.","commonSituations":"Registering a cascading value source as fixed in DI for performance, then later deciding the value should update and calling NotifyChangedAsync without changing the construction; copy-pasting from a dynamic source to a fixed one.","solutions":["Reconstruct/register the CascadingValueSource with isFixed:false if the value needs to change.","Gate the NotifyChangedAsync call behind a check of whether the source is fixed.","If the value is genuinely immutable, remove the NotifyChangedAsync call."],"exampleFix":"// before\nvar source = new CascadingValueSource<MyType>(_initial, isFixed: true);\nservices.Add(new CascadingValueSource<MyType>(source));\nawait source.NotifyChangedAsync(_updated); // throws\n\n// after\nvar source = new CascadingValueSource<MyType>(_initial, isFixed: false);\nservices.Add(new CascadingValueSource<MyType>(source));\nawait source.NotifyChangedAsync(_updated);","handlingStrategy":"validation","validationCode":"if (((ICascadingValueSupplier)source).IsFixed)\n    throw new InvalidOperationException(\"Cannot call NotifyChangedAsync on a fixed source.\");","typeGuard":"static bool CanNotify<T>(CascadingValueSource<T> source)\n    => !((ICascadingValueSupplier)source).IsFixed;","tryCatchPattern":null,"preventionTips":["Construct CascadingValueSource with isFixed:false if you intend to call NotifyChangedAsync.","Store a flag alongside the source indicating whether notifications are allowed."],"tags":["blazor","cascading-value","di","configuration"],"analyzedSha":"294cab2f9b2e03af6b953820c7ab497c3c8b7ad9","analyzedAt":"2026-08-06T20:08:02.189Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}