Lazy Loading and Dependency Injection in Blazor
Hi,
I read the article and tried. I notice that if I do LazyLoading, I cannot do dependency injection for the lazyLoaded assemblies due to container being immutable.
Is there any workaround regarding this ? without having to create a factory class and manually creating your class for dependency.
Regards, Paul
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 690632ad-f357-161f-217b-faba56e90f36
- Version Independent ID: 626c5ed9-6424-7940-56e2-a19989b6de38
- Content: Lazy load assemblies in ASP.NET Core Blazor WebAssembly
- Content Source: aspnetcore/blazor/webassembly-lazy-load-assemblies.md
- Product: aspnet-core
- Technology: aspnetcore-blazor
- GitHub Login: @guardrex
- Microsoft Alias: riande
Hello @ympaul ...
Open this for the product unit at ...
https://github.com/dotnet/aspnetcore/issues
Please add a cc: @guardrex to your opening comment there. I'll re-open this if they provide guidance that we need to add to the topic for this.
Just FYI, the primary way I've solved this issue is as you nodded to and basically use the Service Locator Pattern with a factory class to dynamically resolve the dependencies for the LL assembly at runtime. As you mentioned the DI container is immutable once loaded, and can't resolve a dependency that does not yet exist.
Fear not though, while it's not seamless it's also not too difficult to setup either.