Blazor Wasm - Service was not registered but no exception was thrown. Just hangs

Viewed 24

I had an issue where after navigation to a certain page in the Blazor Wasm project (which requests a service via the [Inject] directive) one of the dependencies in the tree from that initial requested service was not registered in the service collection.

After manually removing constructor arguments down the dependency tree, I eventually found the service that was being requested but had not been registered. I updated the registration to include that service and all was good.

However, I would expect to see a DI exception thrown when a constructor parameter cannot be provided to another service in the container.

Instead, the navigation just hung. Specifically, the URL updated in the browser address bar to the target URL but the page DOM did not update from the page hosting the referring link.

If it makes any difference, the unregistered service was in another project referenced by the client Wasm project. That project had its own IServicesCollection extension method to register the services from that project, but it was here that one of the registrations was missing.

Is this a bug in Blazor or is there something that I'm not aware of that may cause this behaviour?

0 Answers
Related