Open Closed

Exception when attempting to set a dependent module's setting (IsSelfRegistrationEnabled) #2681


User avatar
0
balessi75 created

Abp Commercial / 5.1.3 / EF / Blazor Server

Hi, How does one change a setting for a dependent module programmatically? We followed the documentation at: https://docs.abp.io/en/abp/4.4/Modules/Setting-Management#isettingmanager

We are attempting to set Abp.Account.IsSelfRegistrationEnabled to always be false for the host db only by using the SaasDataSeedContributer in our Domain project (see below). The problem is that the account module settings don't seem to be available to set as we receive the following exception when attempting to set the setting: Volo.Abp.AbpException: 'Undefined setting: Abp.Account.IsSelfRegistrationEnabled'

   public virtual async Task SeedAsync(DataSeedContext context)
    {
        using (_currentTenant.Change(context?.TenantId))
        {
            await _editionDataSeeder.CreateStandardEditionsAsync();

            if (context?.TenantId == null)
            {
          
                await _settingManager.SetForTenantOrGlobalAsync(null, "Abp.Account.IsSelfRegistrationEnabled", "False");

            }
        }
    }
}

4 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Setting definitions in the ..Account.Application project. you can add the Application project reference to the DbMigrator project.

  • User Avatar
    0
    balessi75 created

    Hi,

    Setting definitions in the ..Account.Application project. you can add the Application project reference to the DbMigrator project.

    Hi Liangshiwei,

    I added our ...Application project reference to the DbMigrator project and I am still getting the same exception. The DataSeedContributer is in the Domain project. It needs to be there, correct? I tried adding a DataSeedContributer to the Application project, but DbMigrator does not discover the DataSeedContributer at runtime from that location.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Application project reference to the DbMigrator project and I am still getting the same exception

    Did you add the module dependency?

    [DependsOn(
        .....
        typeof(...ApplicationModule)
        )]
    public class ...DbMigratorModule : AbpModule
    
  • User Avatar
    0
    balessi75 created

    Application project reference to the DbMigrator project and I am still getting the same exception

    Did you add the module dependency?

    [DependsOn( 
        ..... 
        typeof(...ApplicationModule) 
        )] 
    public class ...DbMigratorModule : AbpModule 
    

    That was it! Thanks for the support @liangshiwei

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09