I'm trying to incorporate Blazor WASM into a custom widget, using this article as inspiration https://www.bizstream.com/blog/how-to-integrate-net-8-blazor-server-components-with-kentico-xperience.
I can successfully render the Blazor component outside of the Kentico render body method. If I place this in the _layout it works fine: <component type="typeof(MyComponent)" render-mode="WebAssemblyPrerendered" param-PageTitle="MyTitle" />
However, if I place the same component inside a typical custom widget in the partial view (ie "_MyComponent.cshtml") I get
InvalidOperationException: The current thread is not associated with the Dispatcher. Use InvokeAsync() to switch execution to the Dispatcher when triggering rendering or component state.
From the error I assume it's something to do with the Kentico component rendering process running synchronously whilst Blazor wants to run as async. I've tried changing the Invoke function for the Component to InvokeAsync but the error persists. Would appreciate any help.