abpframework / abp

Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
https://abp.io
GNU Lesser General Public License v3.0
12.77k stars 3.41k forks source link

AutoMapper error for My Modules #11726

Closed AdemAygun closed 2 years ago

AdemAygun commented 2 years ago

Documentation

Please check the official documentation before asking questions: https://docs.abp.io

GitHub Issues

GitHub issues are for bug reports, feature requests and other discussions about the framework.

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

Unmapped properties: Districts

CityUpdateDto -> City (Destination member list) Acme.XProject.Address.Cities.CityUpdateDto -> Acme.XProject.Address.Cities.City (Destination member list)

Unmapped properties: Districts

at Volo.Abp.AutoMapper.AbpAutoMapperModule.<>cDisplayClass2_1.gValidateAll|2(IConfigurationProvider config) at Volo.Abp.AutoMapper.AbpAutoMapperModule.CreateMappings(IServiceProvider serviceProvider) at Autofac.Extensions.DependencyInjection.AutofacRegistration.<>cDisplayClass3_0.b0(IComponentContext context, IEnumerable1 parameters) at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters) at Autofac.Core.Activators.Delegate.DelegateActivator.b2_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.b1(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 --- at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt) at Autofac.Core.Pipeline.ResolvePipeline.Invoke(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Middleware.RegistrationPipelineInvokeMiddleware.Execute(ResolveRequestContext context, Action1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>cDisplayClass14_0.b1(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Middleware.SharingMiddleware.Execute(ResolveRequestContext context, Action`1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>cDisplayClass14_0.b1(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>cDisplayClass14_0.b1(ResolveRequestContext ctxt) at Autofac.Core.Resolving.Middleware.CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action`1 next) at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>cDisplayClass14_0.b1(ResolveRequestContext ctxt) at Autofac.Core.Pipeline.ResolvePipeline.Invoke(ResolveRequestContext ctxt) at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request)
at Autofac.Core.Resolving.ResolveOperation.ExecuteOperation(ResolveRequest request) at Autofac.Core.Resolving.ResolveOperation.Execute(ResolveRequest request) at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(ResolveRequest request) at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 parameters, Object& instance) at Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext context, Service service, IEnumerable1 parameters) at Autofac.ResolutionExtensions.ResolveOptional(IComponentContext context, Type serviceType, IEnumerable`1 parameters) at Autofac.ResolutionExtensions.ResolveOptional(IComponentContext context, Type serviceType) at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetService(Type serviceType) at Microsoft.AspNetCore.Builder.IdentityServerApplicationBuilderExtensions.TestService(IServiceProvider serviceProvider, Type service, ILogger logger, String message, Boolean doThrow) at Microsoft.AspNetCore.Builder.IdentityServerApplicationBuilderExtensions.Validate(IApplicationBuilder app) at Microsoft.AspNetCore.Builder.IdentityServerApplicationBuilderExtensions.UseIdentityServer(IApplicationBuilder app, IdentityServerMiddlewareOptions options) at Acme.XProject.XProjectHttpApiHostModule.OnApplicationInitialization(ApplicationInitializationContext context) in C:\Users\myuser\repos\Acme.XProject\aspnet-core\src\Acme.XProject.HttpApi.Host\XCargoHttpApiHostModule.cs:line 314 at Volo.Abp.Modularity.AbpModule.OnApplicationInitializationAsync(ApplicationInitializationContext context) at Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor.InitializeAsync(ApplicationInitializationContext context, IAbpModule module) at Volo.Abp.Modularity.ModuleManager.InitializeModulesAsync(ApplicationInitializationContext context) --- End of inner exception stack trace --- at Volo.Abp.Modularity.ModuleManager.InitializeModulesAsync(ApplicationInitializationContext context) at Volo.Abp.AbpApplicationBase.InitializeModulesAsync() at Volo.Abp.AbpApplicationWithExternalServiceProvider.InitializeAsync(IServiceProvider serviceProvider) at Microsoft.AspNetCore.Builder.AbpApplicationBuilderExtensions.InitializeApplicationAsync(IApplicationBuilder app) at Acme.XProject.Program.Main(String[] args) in C:\Users\myuser\repos\Acme.XProject\aspnet-core\src\Acme.XProject.HttpApi.Host\Program.cs:line 41

- create a new Solution
- create add new module(Address) and add my main solution
- create City entity and run (runs successfully)
- create District entity and I add new property in Citys `public virtual List<District> Districts { get; set; }`
- Add mappings in AddressApplicationAutoMapperProfile:

public AddressApplicationAutoMapperProfile() { /* You can configure your AutoMapper mapping configuration here.

if I clone all CreateMap lines from AddressApplicationAutoMapperProfile (module) into XProjectApplicationAutoMapperProfile(main) error gones away.

AdemAygun commented 2 years ago

If I add .Ignore(x=>x.Districts) errors gone away

        CreateMap<CityCreateDto, City>().IgnoreFullAuditedObjectProperties().Ignore(x=>x.Districts).Ignore(x => x.ExtraProperties).Ignore(x => x.ConcurrencyStamp).Ignore(x => x.Id);
        CreateMap<CityUpdateDto, City>().IgnoreFullAuditedObjectProperties().Ignore(x=>x.Districts).Ignore(x => x.ExtraProperties).Ignore(x => x.ConcurrencyStamp).Ignore(x => x.Id);
ivansager commented 1 year ago

I am facing the same issue after upgrading to ABP v8 and automapper 12.

System.ArgumentException: Incorrect number of arguments supplied for call to method WasteBirthCertificateChain get_Item(Int32)' (Parameter 'property')

I am not sure yet how to debug this issue but I suspect it happens in CreateMap<WasteBirthCertificateChain, WasteBirthCertificateInput>().ReverseMap().ForMember(x => x.Id, a => a.Ignore());

[@AdemAygun mentioned a .Ignore takes a parameter in the constructor but I do not seem to have that with the current version

AnonymousDotNet commented 1 year ago

I am facing the same issue after upgrading to ABP v8 and automapper 12.

System.ArgumentException: Incorrect number of arguments supplied for call to method WasteBirthCertificateChain get_Item(Int32)' (Parameter 'property')

I am not sure yet how to debug this issue but I suspect it happens in CreateMap<WasteBirthCertificateChain, WasteBirthCertificateInput>().ReverseMap().ForMember(x => x.Id, a => a.Ignore());

[@AdemAygun mentioned a .Ignore takes a parameter in the constructor but I do not seem to have that with the current version

@maliming I also encountered a similar problem after creating a new entity class, but I tried the above method and it still didn't solve it, can you help solve it? Please

maliming commented 1 year ago

@AnonymousDotNet Please create a new issue and share code & steps.

AnonymousDotNet commented 1 year ago

@AnonymousDotNet Please create a new issue and share code & steps.

@maliming I solved it because when I created the mapping, my application layer and domain layer had the same mapping. But the wrong cause of the prompt has bothered me for quite some time. : (