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
ConfigureServices
method. 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; } }
-
0
hi
It is not recommended that you inject services inside the
ConfigureServices
method. 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?
-
0
hi
Is your app
Tiered (MVC) or Identity Server Separated
?The app need to depend on the Saas module