Blazor.IndexedDB.Framework icon indicating copy to clipboard operation
Blazor.IndexedDB.Framework copied to clipboard

Cannot access database from OnAfterRender lifecycle method

Open dmarciano opened this issue 4 years ago • 1 comments

If I try to access the database from the OnAfterRenderAsync lifecycle method, or binding to a method that accesses the database, the following exception is thrown:

One or more errors occurred. (JSRuntime must be set up correctly and must be an instance of JSRuntimeBase to use DotNetObjectRef.)

With the following stack trace:

at Microsoft.JSInterop.DotNetObjectRefManager.get_Current() at Microsoft.JSInterop.DotNetObjectRef`1..ctor(TValue value) at Microsoft.JSInterop.DotNetObjectRef.Create[TValue](TValue value) at TG.Blazor.IndexedDB.IndexedDBManager.OpenDb() at TG.Blazor.IndexedDB.IndexedDBManager.EnsureDbOpen() at TG.Blazor.IndexedDB.IndexedDBManager.GetRecords[TResult](String storeName) at Blazor.IndexedDB.Framework.Extensions.TaskExtensions.InvokeAsyncWithResult(MethodInfo this, Object obj, Object[] parameters) at Blazor.IndexedDB.Framework.IndexedDb.GetRows(Type propertyType, String storeName) at Blazor.IndexedDB.Framework.IndexedDb.LoadData() at Blazor.IndexedDB.Framework.IndexedDb.WaitForConnection() at Blazor.IndexedDB.Framework.IndexedDbFactory.CreateT

However, if I call the same method from a button click it works as expected.

dmarciano avatar Jul 14 '19 09:07 dmarciano

Hi again :) could you maybe provide me an example project with the reproducible misbehaviour? Would be of great help.

Thank you for your patience and have a nice day :)

Reshiru avatar Jul 24 '19 17:07 Reshiru