dotnet/aspnetcore · error · InvalidOperationException

Cannot notify about changes because the {GetType()} is confi

Error message

Cannot notify about changes because the {GetType()} is configured as fixed.

What it means

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.

Source

Thrown at src/Components/Components/src/CascadingValueSource.cs:89

    private CascadingValueSource(bool isFixed)
    {
        _isFixed = isFixed;

        if (!_isFixed)
        {
            _subscribers = new();
        }
    }

    /// <summary>
    /// Notifies subscribers that the value has changed (for example, if it has been mutated).
    /// </summary>
    /// <returns>A <see cref="Task"/> that completes when the notifications have been issued.</returns>
    public Task NotifyChangedAsync()
    {
        if (_isFixed)
        {
            throw new InvalidOperationException($"Cannot notify about changes because the {GetType()} is configured as fixed.");
        }

        if (_subscribers?.Count > 0)
        {
            var tasks = new List<Task>();

            foreach (var (dispatcher, subscribers) in _subscribers)
            {
                tasks.Add(dispatcher.InvokeAsync(() =>
                {
                    var subscribersBuffer = new ComponentStateBuffer();
                    var subscribersCount = subscribers.Count;
                    var subscribersCopy = subscribersCount <= ComponentStateBuffer.Capacity
                        ? subscribersBuffer[..subscribersCount]
                        : new ComponentState[subscribersCount];
                    subscribers.CopyTo(subscribersCopy);

                    // We iterate over a copy of the list because new subscribers might get

View on GitHub (pinned to 294cab2f9b)

Solutions

  1. Reconstruct/register the CascadingValueSource with isFixed:false if the value needs to change.
  2. Gate the NotifyChangedAsync call behind a check of whether the source is fixed.
  3. If the value is genuinely immutable, remove the NotifyChangedAsync call.

Example fix

// before
var source = new CascadingValueSource<MyType>(_initial, isFixed: true);
services.Add(new CascadingValueSource<MyType>(source));
await source.NotifyChangedAsync(_updated); // throws

// after
var source = new CascadingValueSource<MyType>(_initial, isFixed: false);
services.Add(new CascadingValueSource<MyType>(source));
await source.NotifyChangedAsync(_updated);
Defensive patterns

Strategy: validation

Validate before calling

if (((ICascadingValueSupplier)source).IsFixed)
    throw new InvalidOperationException("Cannot call NotifyChangedAsync on a fixed source.");

Type guard

static bool CanNotify<T>(CascadingValueSource<T> source)
    => !((ICascadingValueSupplier)source).IsFixed;

Prevention

When it happens

Trigger: Calling NotifyChangedAsync() or NotifyChangedAsync(newValue) on a CascadingValueSource that was created with isFixed:true. The guard is at CascadingValueSource.cs:87-90.

Common situations: 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.

Related errors


AI-assisted analysis of dotnet/aspnetcore@294cab2f9b (2026-08-06). Data as JSON: /api/errors/da48d3cee1cc3869. Report an issue: GitHub.