Open Closed

Adding project Volo.Abp.MultiTenancy from Github into ABP solution #1490


User avatar
0
christophe.baille created

ABP Framework version: v4.3.2 UI type: Angular DB provider: EF Core Tiered (MVC) or Identity Server Separated (Angular): no

On my actual solution, I would like to add a part of the framework source code. On my case it is Volo.Abp.MultiTenancy. So I first did download the Framework from GitHub https://github.com/abpframework/abp Then I created a new folder "framework" into my solution and copy the project folder Volo.Abp.MultiTenancy into it.

From this project, I had to make few changes on the csproj file to get it loaded properly. Change the path of 2 props files that I did copy to the solution too and change the reference from project to package:

From now, I have my project loading properly and I can run the application properly.

My issue now is on how could I add a reference to replace the Volo.Abp.MultiTenancy from the Nuget (C:\Users\OS.nuget\packages\volo.abp.multitenancy\4.3.2) by the one from my project, either for the whole solution or to make it individually for each project.

I to add this to one project but then I can not run the solution anymore:

<ProjectReference Include="....\framework\Volo.Abp.MultiTenancy\Volo.Abp.MultiTenancy.csproj"/>

Is there any step or anything that I miss?

Thanks


9 Answer(s)
  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    You need to build all project references. If you have downloaded the framework, there is a build folder. try running build-all.ps1.

  • User Avatar
    0
    christophe.baille created

    Sorry for the late reply.

    Does it means that I need to add the whole framework to my source code? I can not add only Volo.Abp.MultiTenancy?

    I built the project added successfully by right click as you can see:

  • User Avatar
    0
    alper created
    Support Team Director

    add the complete framework or I didn't test but, you can try to add the individual project change the project references to NuGet reference.

  • User Avatar
    0
    christophe.baille created

    It still doesn't work. I will explain what I want to do an how I proceed:

    I want to edit the method Volo.Abp.MultiTenancy.TenantConfigurationProvider.GetAsync(bool saveResolveResult) as it return an error in case DomainTenantResolver do not find a tenant. I want to make the tenant choice visible if so

    To add Volo.Abp.MultiTenancy project on my solution, I need first to add Volo.Abp.AspNetCore.MultiTenancy source on HttpApi.Host project.

    After that, it keep running well, the solution is fine.

    The next step is to add Volo.Abp.MultiTenancy source code as it is on it I want to edit my method, so I replace 1 by 2

    I then replaced reference from project to the one from packages (I did the same for Volo.Abp.AspNetCore.MultiTenancy too:

    But then I got this errors.

    In case it can be usefull, the difference between this projects is that Volo.Abp.AspNetCore.MultiTenancy is Microsoft.NET.Sdk.Web (net5.0) and Volo.Abp.MultiTenancy is Microsoft.NET.Sdk (netstandard2.0)

  • User Avatar
    0
    christophe.baille created

    From the log file, it seems there is an issue of mapping with IsActive. I am a bit confused to have this error when using code from project and not from the Package as both have same version...

    2021-07-13 19:27:04.505 +07:00 [FTL] Application startup exception Volo.Abp.AbpInitializationException: An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module Kwork.StaffApp.StaffAppHttpApiHostModule, Kwork.StaffApp.HttpApi.Host, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: An exception was thrown while activating Volo.Abp.IdentityServer.Grants.PersistedGrantStore -> Volo.Abp.ObjectMapping.DefaultObjectMapper1[[Volo.Abp.IdentityServer.AbpIdentityServerDomainModule, Volo.Abp.IdentityServer.Domain, Version=4.3.2.0, Culture=neutral, PublicKeyToken=null]] -> Volo.Abp.AutoMapper.AutoMapperAutoObjectMappingProvider1[[Volo.Abp.IdentityServer.AbpIdentityServerDomainModule, Volo.Abp.IdentityServer.Domain, Version=4.3.2.0, Culture=neutral, PublicKeyToken=null]] -> λ:Volo.Abp.AutoMapper.IMapperAccessor -> λ:Volo.Abp.AutoMapper.MapperAccessor.. See the inner exception for details. ---> Autofac.Core.DependencyResolutionException: An exception was thrown while activating Volo.Abp.IdentityServer.Grants.PersistedGrantStore -> Volo.Abp.ObjectMapping.DefaultObjectMapper1[[Volo.Abp.IdentityServer.AbpIdentityServerDomainModule, Volo.Abp.IdentityServer.Domain, Version=4.3.2.0, Culture=neutral, PublicKeyToken=null]] -> Volo.Abp.AutoMapper.AutoMapperAutoObjectMappingProvider1[[Volo.Abp.IdentityServer.AbpIdentityServerDomainModule, Volo.Abp.IdentityServer.Domain, Version=4.3.2.0, Culture=neutral, PublicKeyToken=null]] -> λ:Volo.Abp.AutoMapper.IMapperAccessor -> λ:Volo.Abp.AutoMapper.MapperAccessor. ---> AutoMapper.AutoMapperConfigurationException: Unmapped members were found. Review the types and members below. Add a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type For no matching constructor, add a no-arg ctor, add optional arguments, or map all of the constructor parameters

    Tenant -> TenantConfiguration (Destination member list) Volo.Saas.Tenants.Tenant -> Volo.Abp.MultiTenancy.TenantConfiguration (Destination member list)

    Unmapped properties: IsActive

    at Volo.Abp.AutoMapper.AbpAutoMapperModule.<>c__DisplayClass2_1.<CreateMappings>g__ValidateAll|2(IConfigurationProvider config) at Volo.Abp.AutoMapper.AbpAutoMapperModule.CreateMappings(IServiceProvider serviceProvider) at Autofac.Extensions.DependencyInjection.AutofacRegistration.<>c__DisplayClass3_0.<Register>b__0(IComponentContext context, IEnumerable1 parameters) at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters) at Autofac.Core.Activators.Delegate.DelegateActivator.<ConfigurePipeline>b__2_0(ResolveRequestContext ctxt, Action1 next) at Autofac.Core.Resolving.Middleware.DelegateMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action1 next) --- End of inner exception stack trace ---

  • User Avatar
    0
    alper created
    Support Team Director

    But why you don't just override the GetAsync() method of TenantConfigurationProvider in your project. This method is virtual and you can override it. Create your own custom class and override it in your domain project.

    [Volo.Abp.DependencyInjection.Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(IdentityUserManager))]
    public class MyTenantConfigurationProvider : TenantConfigurationProvider
    {
        public MyTenantConfigurationProvider(
            ITenantResolver tenantResolver,
            ITenantStore tenantStore, 
            ITenantResolveResultAccessor tenantResolveResultAccessor) : 
            base(tenantResolver, tenantStore, tenantResolveResultAccessor)
        {
        }
    
        public override async Task<TenantConfiguration> GetAsync(bool saveResolveResult = false)
        {
            return await Task.FromResult(new TenantConfiguration(Guid.Empty, "dummy"));
        }
    }
    

    Reference: https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Overriding-Services

  • User Avatar
    0
    christophe.baille created

    Hello,

    Thanks it works well, I was worrying about having to add so much Frameworksource on my solution.

    About the source code, I do not think I took the wrong Framework source, but I need to remove some code from the original method as IsActive does not exist

    On last point that you might be able to tell me if possible or not. I wanted to edit the footer of the MVC view from Lepton Theme, so I did add the whole module Volo.Abp.AspNetCore.Mvc.UI.Theme.Lepton in my solution just to edit one file...

    I did follow this:

    https://docs.abp.io/en/abp/latest/UI/AspNetCore/Customization-User-Interface#overriding-a-razor-page-cshtml

    I did it already to change the register page, but it seems not working for my Lepton Theme. See as below, on the left it is the solution as added, you can see the path of the file. On the right, Register.cshtml replace the original one. I created a folder path for my footer, but it does not take it, I should but this _Footer.cshtml in another folder or it is just not possible to replace like this?

  • User Avatar
    0
    alper created
    Support Team Director

    could you pls create a new ticket for the new question.

  • User Avatar
    0
    christophe.baille created

    The error I made was to have missed the s on Layouts folder name, no worth a ticket...

Made with ❤️ on ABP v9.1.0-preview. Updated on December 12, 2024, 07:15