Hello,
I need to inject tenantRepository or tenantApppService in ConfigureServices method in DocsWebModule.cs. I need to check tenant db connectionSetting before configuring menu contributor. But I can not register in ConfigureServices.
Can you give an example?
Thanks
ABP Framework version: v5.3.2
UI type: / MVC /
DB provider: EF Core
Tiered (MVC) or Identity Server Separated (Angular): yes / no
Exception message and stack trace:
Steps to reproduce the issue:"
3 Answer(s)
-
0
hi
It is not recommended that you inject services inside the
ConfigureServicesmethod. The dependency injection container has not been created yet.I need to check tenant db connectionSetting before configuring menu contributor.
You can inject the services in
menu contributor.public class AbpAccountUserMenuContributor : IMenuContributor { public virtual Task ConfigureMenuAsync(MenuConfigurationContext context) { var tenantRepository = context.ServiceProvider.GetRequiredService<ITenantRepository>(); return Task.CompletedTask; } }Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post) -
0
hi
It is not recommended that you inject services inside the
ConfigureServicesmethod. The dependency injection container has not been created yet.I need to check tenant db connectionSetting before configuring menu contributor.
You can inject the services in
menu contributor.public class AbpAccountUserMenuContributor : IMenuContributor { public virtual Task ConfigureMenuAsync(MenuConfigurationContext context) { var tenantRepository = context.ServiceProvider.GetRequiredService<ITenantRepository>(); return Task.CompletedTask; } }I tried this solution first, but I get an error like this. What would be the reason?
Markdown supported.Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

