Open Kukks opened 3 years ago
The most logical reason would be that you inject IJSRuntime in a class that is registered as Singleton. IJSRuntime is registered as scoped because it is setup and torn down between page(reloads) en while navigating away etc. You cannot inject it into a singleton. Change the registration from Singleton to scoped and it should work. Also think about the fact that Blazor can be unloaded and reloaded on demand (e.g. during screen rotation, when the app is put into the background, or when navigating away to an external link. So make sure that all tear-down and setup happens nicely and that you persist state (if you have to), because you cannot be sure that Blazor keeps running.
@Kukks I ran exactly into this error. I fix it using xamarin essentials secure storage instead of browser storage when working with native devices. I did a common interface which manage platform storage.
@Kukks I ran exactly into this error. I fix it using xamarin essentials secure storage instead of browser storage when working with native devices. I did a common interface which manage platform storage.
Thank you for the idea :) it works fine on Android by following this instructions . On the windows application, I got this exception:
System.AggregateException: 'One or more errors occurred. (This functionality is not implemented in the portable version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation.)'.
This exception was originally thrown at this call stack:
Xamarin.Essentials.SecureStorage.PlatformGetAsync(string)
Xamarin.Essentials.SecureStorage.GetAsync(string)
MyApplication.App.MyTask() in App.cs
How can I store on secure storage from the windows application? Thank you in advance
@husam-ebish, use MBB's own ProtectedStorage:
@Kukks I ran exactly into this error. I fix it using xamarin essentials secure storage instead of browser storage when working with native devices. I did a common interface which manage platform storage.
Thank you for the idea :) it works fine on Android by following this instructions . On the windows application, I got this exception:
System.AggregateException: 'One or more errors occurred. (This functionality is not implemented in the portable version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation.)'.
This exception was originally thrown at this call stack: Xamarin.Essentials.SecureStorage.PlatformGetAsync(string) Xamarin.Essentials.SecureStorage.GetAsync(string) MyApplication.App.MyTask() in App.cs
How can I store on secure storage from the windows application? Thank you in advance
Xamarin essentials is not supported on win32/wpf but a port is being developed
Take a look of this PR
Version: 0.6.18-preview Platform: Windows WPF Exception:
Cause: When loading a component inside hybrid blazor app inside MBB Windows, that uses
IJSRuntime
(in my case it is a call tolocalstorage.get
), nested underOnAfterRenderAsync(firstRender)
where firstRender is true.Source: https://github.com/Kukks/Hara/tree/bump-and-fix-windows-support