dotnet / MobileBlazorBindings

Experimental Mobile Blazor Bindings - Build native and hybrid mobile apps with Blazor
MIT License
1.21k stars 172 forks source link

Blazor Hybrid App (Windows) throws an exception when using JsInterop "too early" #386

Closed Kukks closed 3 years ago

Kukks commented 3 years ago

When using MBB with Windows with a fully Blazor Web UI, and the first page renders, and calls OnAfterRenderAsync, I get an exception stating that "AttachToIpcChannel must be called before using IJSRuntime".

image

Is there something I can check or await?

Eilon commented 3 years ago

Hi @Kukks does this look the same or similar to these previous issues?

Kukks commented 3 years ago

Hi @Kukks does this look the same or similar to these previous issues?

Hah, seems like I'm falling down the same pitfalls as I start gearing up again to using MBB :)

It was indeed solved by ensuring all services that use IJsRuntime are configured as Transient or Scoped!