Closed Apskaita5 closed 2 years ago
@Apskaita5 Can you provide us with a complete exception call stack?
An unhandled exception occurred while processing the request. AggregateException: Exceptions were encountered while disposing components. (The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.) (The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.) (The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.) (The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.) (The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.) (The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.) Microsoft.AspNetCore.Components.Rendering.HtmlRenderer.HandleException(Exception exception)
InvalidOperationException: The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state. Microsoft.AspNetCore.Components.Dispatcher.AssertAccess()
InvalidOperationException: The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state. Microsoft.AspNetCore.Components.Dispatcher.AssertAccess()
InvalidOperationException: The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state. Microsoft.AspNetCore.Components.Dispatcher.AssertAccess()
InvalidOperationException: The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state. Microsoft.AspNetCore.Components.Dispatcher.AssertAccess()
InvalidOperationException: The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state. Microsoft.AspNetCore.Components.Dispatcher.AssertAccess()
InvalidOperationException: The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state. Microsoft.AspNetCore.Components.Dispatcher.AssertAccess()
Stack Query Cookies Headers Routing
AggregateException: Exceptions were encountered while disposing components. (The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.) (The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.) (The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.) (The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.) (The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.) (The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.)
Microsoft.AspNetCore.Components.Rendering.HtmlRenderer.HandleException(Exception exception)
Microsoft.AspNetCore.Components.RenderTree.Renderer.
Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.SetOutputContentAsync()
HavitBlazorTest.Pages.PagesHost.ExecuteAsync() in _Host.cshtml
+
Layout = null;
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, bool invokeViewStarts)
Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, string contentType, Nullable
Show raw exception details
InvalidOperationException: The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.
Microsoft.AspNetCore.Components.Dispatcher.AssertAccess()
Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToRenderQueue(int componentId, RenderFragment renderFragment)
Microsoft.AspNetCore.Components.ComponentBase.StateHasChanged()
Havit.Blazor.Components.Web.CollectionRegistration
Show raw exception details
InvalidOperationException: The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.
Microsoft.AspNetCore.Components.Dispatcher.AssertAccess()
Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToRenderQueue(int componentId, RenderFragment renderFragment)
Microsoft.AspNetCore.Components.ComponentBase.StateHasChanged()
Havit.Blazor.Components.Web.CollectionRegistration
Show raw exception details
InvalidOperationException: The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.
Microsoft.AspNetCore.Components.Dispatcher.AssertAccess()
Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToRenderQueue(int componentId, RenderFragment renderFragment)
Microsoft.AspNetCore.Components.ComponentBase.StateHasChanged()
Havit.Blazor.Components.Web.CollectionRegistration
Show raw exception details
InvalidOperationException: The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.
Microsoft.AspNetCore.Components.Dispatcher.AssertAccess()
Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToRenderQueue(int componentId, RenderFragment renderFragment)
Microsoft.AspNetCore.Components.ComponentBase.StateHasChanged()
Havit.Blazor.Components.Web.CollectionRegistration
Show raw exception details
InvalidOperationException: The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.
Microsoft.AspNetCore.Components.Dispatcher.AssertAccess()
Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToRenderQueue(int componentId, RenderFragment renderFragment)
Microsoft.AspNetCore.Components.ComponentBase.StateHasChanged()
Havit.Blazor.Components.Web.CollectionRegistration
Show raw exception details
InvalidOperationException: The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.
Microsoft.AspNetCore.Components.Dispatcher.AssertAccess()
Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToRenderQueue(int componentId, RenderFragment renderFragment)
Microsoft.AspNetCore.Components.ComponentBase.StateHasChanged()
Havit.Blazor.Components.Web.CollectionRegistration
Is seems the exception comes from the HxGridColumnBase.Dispose()
method where there is StateHasChanged()
callback and in server-prerendering mode, under some circumstances, the Dispose
method is called out of Dispatcher
thread.
@jirikanda Can you look into it? ...it is probably the StateHasChanged
in component-registration we touched yesterday. Wrapping with InvokeAsync()
might help?
Hi guys,
I read the callstack the same way:
Dispose
method is called out of Dispatcher
thread.@hakenr It could be connected with ConfigureAwait we also discussed yesterday.
Unfortunatelly, I am not able to reproduce the issue. Reproducing the issue is necessary to verify the fix. @Apskaita5, could you provide more information, please? We need reprosteps like we did for another issue, ie. Issue102Test.razor Alternatively, you can provide a small git repository with reprosteps.
I was unable to reproduce the issue when writing from scratch too :) I guess I created some very exotic mix in my test project (attached). HavitBlazorTest.zip
@Apskaita5, thank you very much for your reprosteps.
I analyzed the attached code and successfully reproduced the issue. It is quite tricky while to reproduce the issue:
@(forecasts ?? new List<WeatherForecast>())
in your code)).While the problem is in the 2nd point, I guess the points 1 and 3 are "the initiators" of the problem and I hope they will lead me to the source of the problem.
@hakenr, ConfigureAwait mentioned before is not connected to the issue.
To be continued...
Fixed.
If you use async parameter setting in OnParametersSetAsync or OnInitializedAsync, e.g.
protected override async Task OnInitializedAsync() { try { await Task.Delay(100); forecasts = new List();
}
catch (Exception ex)
{
MessengerService.AddError(ex.Message);
}
}
and have a HxTabPanel on the component, on page refresh you get an excpetion: "InvalidOperationException: The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state."
No problems with other Havit components I tried.
I can solve the problem by moving async load operation to OnAfterRenderAsync. However, as it only happens with the HxTabPanel, I believe something is wrong with its implementation.