Skip to content
This repository was archived by the owner on Dec 26, 2025. It is now read-only.

[Bug] OnChange Invoke error on ISyncLocalStorageService .NET 9 #253

Description

@B2BSystems

Describe the bug
IJSInProcessRuntime not available is thrown when trying to read from local storage.
Developing a cart where I use OnChange event to update the cart item counter. This have worked before with older .NET version.

To Reproduce

@inject Blazored.LocalStorage.ISyncLocalStorageService LocalStorage
@implements IDisposable

....

private int GetCartItemCount()
{
    var cart = LocalStorage.GetItem<List<CartItemDto>>("b_cart"); // ERROR: IJSInProcessRuntime not available
    return cart != null ? cart.Count : 0;
}

// subscribe to the cart changes event
protected override void OnInitialized()
{
    CartService.OnChange += StateHasChanged;
}

public void Dispose()
{
    CartService.OnChange -= StateHasChanged;
}

After adding items to the cart I invoke the OnChange event.

public event Action OnChange;

....

await _localStorage.SetItemAsync("b_cart", cart);
OnChange.Invoke();

Expected behavior
Counter should be updated with number of items in cart.

Hosting Model (is this issue happening with a certain hosting model?):

  • Blazor WebAssembly .NET 9

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingTriageIssue needs to be triaged

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions