Plotly.Blazor
Plotly.Blazor copied to clipboard
Stacked Bar Chart - chart.React() - Cannot access a disposed object.\r\nObject name: 'DotNetObjectReference
I am trying to update a stacked bar chart that is being used in a dashboard every 5 minutes or so and also has the capability of being able to be manually refreshed whenever the user wants to. When calling chart.React() this is the error I am getting. Cannot access a disposed object. Object name: 'DotNetObjectReference`1'.
With a stack trace of: at Microsoft.JSInterop.DotNetObjectReference1.ThrowIfDisposed() at Microsoft.JSInterop.DotNetObjectReference1.get_Value() at Plotly.Blazor.PlotlyJsInterop.<React>d__3.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Plotly.Blazor.PlotlyChart.<React>d__49.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Code being used to update the chart:
if (_chart != null) { await InvokeAsync(async () => { await _chart.React(); }); }
This same code works fine for the Line (Scatter) charts for updating values in realtime/manual refresh.
I also get this error rather frequently. Truthfully, I just wrapped it in a try/catch/do nothing and ignore it for now (Chart will update on my next cycle), but if there is a better solution I would love to hear it.
FWIW I am also getting the same error on a waterfall chart.