Open Closed

Get Exception after add permission management module #6303


User avatar
0
sandeep.step2gen@gmail.com created
  • ABP Framework version: v7.3.2
  • UI Type: Angular
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): NO
  • Exception message and full stack trace:
  • System.IO.FileNotFoundException: Could not load file or assembly 'Volo.Abp.PermissionManagement.Domain, Version=7.3.2.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. File name: 'Volo.Abp.PermissionManagement.Domain, Version=7.3.2.0, Culture=neutral, PublicKeyToken=null' at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, RuntimeType type, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs) at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder1 derivedAttributes) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit) at System.Attribute.GetCustomAttributes(MemberInfo element, Boolean inherit) at Volo.Abp.Modularity.AbpModuleHelper.FindDependedModuleTypes(Type moduleType) at Volo.Abp.Modularity.AbpModuleHelper.AddModuleAndDependenciesRecursively(List1 moduleTypes, Type moduleType, ILogger logger, Int32 depth) at Volo.Abp.Modularity.AbpModuleHelper.AddModuleAndDependenciesRecursively(List1 moduleTypes, Type moduleType, ILogger logger, Int32 depth) at Volo.Abp.Modularity.AbpModuleHelper.AddModuleAndDependenciesRecursively(List1 moduleTypes, Type moduleType, ILogger logger, Int32 depth) at Volo.Abp.Modularity.AbpModuleHelper.AddModuleAndDependenciesRecursively(List1 moduleTypes, Type moduleType, ILogger logger, Int32 depth) at Volo.Abp.Modularity.AbpModuleHelper.FindAllModuleTypes(Type startupModuleType, ILogger logger) at Volo.Abp.Modularity.ModuleLoader.FillModules(List1 modules, IServiceCollection services, Type startupModuleType, PlugInSourceList plugInSources) at Volo.Abp.Modularity.ModuleLoader.GetDescriptors(IServiceCollection services, Type startupModuleType, PlugInSourceList plugInSources) at Volo.Abp.Modularity.ModuleLoader.LoadModules(IServiceCollection services, Type startupModuleType, PlugInSourceList plugInSources) at Volo.Abp.AbpApplicationBase.LoadModules(IServiceCollection services, AbpApplicationCreationOptions options) at Volo.Abp.AbpApplicationBase..ctor(Type startupModuleType, IServiceCollection services, Action1 optionsAction) at Volo.Abp.AbpApplicationWithExternalServiceProvider..ctor(Type startupModuleType, IServiceCollection services, Action1 optionsAction) at Volo.Abp.AbpApplicationFactory.Create(Type startupModuleType, IServiceCollection services, Action1 optionsAction) at Volo.Abp.AbpApplicationFactory.CreateAsync[TStartupModule](IServiceCollection services, Action1 optionsAction) at Microsoft.Extensions.DependencyInjection.ServiceCollectionApplicationExtensions.AddApplicationAsync[TStartupModule](IServiceCollection services, Action1 optionsAction) at Microsoft.Extensions.DependencyInjection.WebApplicationBuilderExtensions.AddApplicationAsync[TStartupModule](WebApplicationBuilder builder, Action1 optionsAction) at v3.spathios.Program.Main(String[] args) in C:\Step2gen\Spathios\Backend\aspnetcore\src\v3.spathios.HttpApi.Host\Program.cs:line 38`
  • Steps to reproduce the issue:
  • Add permission module into your solution with this command abp add-module Volo.PermissionManagement --with-source-code --add-to-solution-file
  • and try to run project


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

    Hi,

    This is because the permission module is a basic module and other module dependencies depend on it through package references.

    So I don't recommend you to add it.

    You can explain your use case and I will try to help you

  • User Avatar
    0
    sandeep.step2gen@gmail.com created

    I understand your point. Thank you for clarifying I'd like for any updates made to role permissions by the Host Tenant to be reflected across all tenants in the application, updating roles with identical names."

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can override the PermissionAppService

    For example: (no test)

    [ExposeServices(typeof(IPermissionAppService))]
    public class MyPermissionAppService : PermissionAppService
    {
        private readonly ITenantRepository _tenantRepository;
        private readonly IIdentityRoleRepository _identityRoleRepository;
        private readonly ILookupNormalizer _lookupNormalizer;
    
        public MyPermissionAppService(
            IPermissionManager permissionManager,
             IPermissionDefinitionManager permissionDefinitionManager,
             IOptions<PermissionManagementOptions> options,
             ISimpleStateCheckerManager<PermissionDefinition> simpleStateCheckerManager,
             ITenantRepository tenantRepository,
             IIdentityRoleRepository identityRoleRepository,
             ILookupNormalizer lookupNormalizer) : base(permissionManager, permissionDefinitionManager, options, simpleStateCheckerManager)
        {
            _tenantRepository = tenantRepository;
            _identityRoleRepository = identityRoleRepository;
            _lookupNormalizer = lookupNormalizer;
        }
    
        public override async Task UpdateAsync(string providerName, string providerKey, UpdatePermissionsDto input)
        {
            if(providerName != RolePermissionValueProvider.ProviderName || CurrentTenant.IsAvailable)
            {
                await base.UpdateAsync(providerName, providerKey, input);
                return;
            }
    
            await base.UpdateAsync(providerName, providerKey, input);
    
            await UpdateAllTenantRolesAsync(providerName, providerKey, input);
        }
    
        private async Task UpdateAllTenantRolesAsync(string providerName, string providerKey, UpdatePermissionsDto input)
        {
            var roleName = (await _identityRoleRepository.GetAsync(Guid.Parse(providerKey))).Name;
            
            var tenants = await _tenantRepository.GetListAsync();
            foreach(var tenant in tenants)
            {
                using(CurrentTenant.Change(tenant.Id))
                {
                    var tenantRole = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName(roleName));
                    if(tenantRole == null)
                    {
                        continue;
                    }
    
                    await base.UpdateAsync(providerName, tenantRole.Id.ToString(), input);
                }
                
            }
        }
    }
    
  • User Avatar
    0
    sandeep.step2gen@gmail.com created

    Thanks liangshiwei, Its working btw for roles ABP is saving the role name for the ProviderKey. apart from that all the code is working

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    I remember it wrong. I thought it was Id, good to hear that it working for you.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11