Open Closed

ISettingManager not available in module #3694


User avatar
0
maksym created

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, please use the search on the homepage.

If you're creating a bug/problem report, please include followings:

  • ABP Framework version: v4.3.0
  • UI type: Blazor
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes
    • Exception message and stack trace:
  • Steps to reproduce the issue:"

We are unable to get dependency injection of ISettingManager in the constructor of a Blazor component we created to configure the settings for a module.

The module which uses the ISettingManager is as follows:

This has worked in a separate ABP Blazor solution, but in this case we have it in a separate module in another ABP solution and when visiting the respective page we get this error:


10 Answer(s)
  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi, I guess you've created a new module and want to use the ISettingManager on it, right?

    If so, please ensure you added the related depends on statement to your module class (ensure your domain module depends on the AbpSettingManagementDomainModule ([DependsOn(typeof(AbpSettingManagementDomainModule))])).

  • User Avatar
    0
    maksym created

    Hi, I guess you've created a new module and want to use the ISettingManager on it, right?

    If so, please ensure you added the related depends on statement to your module class (ensure your domain module depends on the AbpSettingManagementDomainModule ([DependsOn(typeof(AbpSettingManagementDomainModule))])).

    That is correct, I've created a new Module using ABP Suite and want to setup Settings specifically within that module.

    I've already added that dependency to the Module's Domain Module:

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    That is correct, I've created a new Module using ABP Suite and want to setup Settings specifically within that module.

    I've already added that dependency to the Module's Domain Module:

    Thanks for the confirmation. I'll try to reproduce it and write you back asap.

  • User Avatar
    0
    maksym created

    I was wondering if it could be because it was a long-lived ABP solution and we did a lot of changes to it. But I created a brand new ABP Solution and created a module within that Solution and tried again and still couldn't get ISettingManagement to work in the module.

    btw, I used ABP suite to create this module within the solution (both times) using this button:

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    I was wondering if it could be because it was a long-lived ABP solution and we did a lot of changes to it. But I created a brand new ABP Solution and created a module within that Solution and tried again and still couldn't get ISettingManagement to work in the module.

    btw, I used ABP suite to create this module within the solution (both times) using this button:

    Hi, yes it might be related to your changes but it's weird to see this problem in a brand new solution. I'll test and write you back within the day. Sorry for the delay.

  • User Avatar
    0
    maksym created

    Hi, were you able to replicate the issue? Or are you able to get ISettingManager in a module instantiated in an ABP solution?

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    The module which uses the ISettingManager is as follows:

    Can you use the Inject attribute instead of constructor injection as below and try again:

        public partial class NewsSettingGroupComponent
        {
            [Inject]
            public ISettingManager SettingManager {get; set;}
        
        }
    

    Btw, to be able to use the ISettingManager in the blazor project, your project should depends on SettingManagement.Domain package (directly or indirectly).

  • User Avatar
    0
    maksym created

    Hi,

    I tried using the Inject attribute and it still didn't work.

    I've reproduced the error on a clean ABP Solution, here is the link: https://github.com/maksym-gryb/ABPTestSolution

    Please try it out and let me know how we can resolve this issue in our codebase.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi,

    I tried using the Inject attribute and it still didn't work.

    I've reproduced the error on a clean ABP Solution, here is the link: https://github.com/maksym-gryb/ABPTestSolution

    Please try it out and let me know how we can resolve this issue in our codebase.

    Thanks, I'll clone your repository and try to reproduce it.

  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi, I examine your project and find a small problem. It seems your blazor project (TestModuleABlazorModule) depends on your domain project (TestModuleADomainModule) and it should not be like that. Instead, you should create an application service and use the ISettingManager on it.

    Then, use the application service interface instead the ISettingManager.


    For an example please check the below links:

    1-) Using ISettingManager in an application service -> https://github.com/abpframework/abp/blob/dev/modules/setting-management/src/Volo.Abp.SettingManagement.Application/Volo/Abp/SettingManagement/EmailSettingsAppService.cs#L13

    2-) Using the related application service in the setting management group -> https://github.com/abpframework/abp/blob/dev/modules/setting-management/src/Volo.Abp.SettingManagement.Blazor/Pages/SettingManagement/EmailSettingGroup/EmailSettingGroupViewComponent.razor.cs#L17

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11