First of all, A little background: This is an app that started as a standalone Blazor project. I later added a Server-Side Blazor project to call into the standalone one (as a way to debug things locally before i publish the standalone one). I upgraded those throughout the Blazor versions and now into 0.9. It's quite likely i am doing something bad/unsupported/broken.
I have a login component that gets injected with ILocalStorageService and attempts to call SetItem on a successful login (<form onsubmit="async () => await DoStuffAndCallStorage()").
This throws an exception as such:
System.InvalidOperationException: IJSInProcessRuntime not available
at Blazored.LocalStorage.LocalStorageService.Blazored.LocalStorage.ISyncLocalStorageService.GetItem[T](String key)
at Blazored.LocalStorage.LocalStorageService.GetItem(String key)
at Blazored.LocalStorage.LocalStorageService.RaiseOnChanging(String key, Object data, ChangingEventArgs& e)
at Blazored.LocalStorage.LocalStorageService.SetItem(String key, Object data)
This used to work in 1.0.1, But quite a few things changed in this library since. I believe this is related to these changes:
.. where the call to GetItem inside the event handler is forcing the usage of the sync version, Which obviously fails if you're in an async scenario/didn't inject the sync version on purpose to begin with.
First of all, A little background: This is an app that started as a standalone Blazor project. I later added a Server-Side Blazor project to call into the standalone one (as a way to debug things locally before i publish the standalone one). I upgraded those throughout the Blazor versions and now into 0.9. It's quite likely i am doing something bad/unsupported/broken.
I have a login component that gets injected with
ILocalStorageService
and attempts to callSetItem
on a successful login (<form onsubmit="async () => await DoStuffAndCallStorage()"
).This throws an exception as such:
This used to work in 1.0.1, But quite a few things changed in this library since. I believe this is related to these changes:
https://github.com/Blazored/LocalStorage/blob/58b1c5577adf4f7d5b251cb24e3b0a2cecc72825/src/Blazored.LocalStorage/LocalStorageService.cs#L135
https://github.com/Blazored/LocalStorage/blob/58b1c5577adf4f7d5b251cb24e3b0a2cecc72825/src/Blazored.LocalStorage/LocalStorageService.cs#L127
.. where the call to
GetItem
inside the event handler is forcing the usage of the sync version, Which obviously fails if you're in an async scenario/didn't inject the sync version on purpose to begin with.