Base solution for your next web application
Open Closed

Attribute based AutoMapping cannot resolve typeof(class) in Application.Shared DTO's in AspNetZero 8.9.2 #9234


User avatar
0
compassinformatics17 created

Hi All,

I wonder if someone might help to shed some light on an issue which I have noticed. I am putting together a project in AspNetZero Core MVC & Jquery. All is working well except I encountered an issue with the Abp.AutoMapper.

In the documentation there are two AutoMapping methods mentioned:

"CustomDtoMapper.cs is used to create mapping from Person to PersonListDto. FullAuditedEntityDto is inherited to implement audit properties automatically. See application service and DTO documentations for more information. We are adding the following mappings."

And

"We use Abp.AutoMapper library that makes usage of AutoMapper simpler and declarative."

But the example given on the page https://docs.aspnetzero.com/en/aspnet-core-mvc/latest/Infrastructure-Core-Mvc-Dto-Mappings is no longer representative of what is in the codebase, that mapping is now done in CustomDtoMapper.cs.

configuration.CreateMap<Tenant, TenantListDto>();
configuration.CreateMap<TenantEditDto, Tenant>().ReverseMap();

My issue is that Abp.AutoMapper does not seem to work at all from Application.Shared project in any DTO's. For instance if I try to enter the example on the above page in TenantEditDto.cs the Tenant class cannot be resolved.

using System;
using System.ComponentModel.DataAnnotations;
using Abp.Application.Services.Dto;
using Abp.Auditing;
using Abp.AutoMapper;
using Abp.MultiTenancy;

namespace CompassCorejQueryDemo.MultiTenancy.Dto
{
    [AutoMap(typeof(Tenant))]  //Tenant cannot be resolved here. I have tried the same in many other existing DTO's and in my own ones, but all behave the same, the typeof(class) cannot be resolved.

I have checked and Abp.AutoMapper is still used in other models and in the GraphQL DTO's but not in Application.Shared. All DTO's in Application.Shared are now handled by AutoMapper in CustomDtoMapper.cs.

I cross checked with an Asp.Net Zero MVC5 project and it matches exactly with the exception that Abp.AutoMapper works as intended in the MVC5 project.

Is there a reason for this change or am I missing something obvious? Any advice is appreciated.

Regards, Barry.


1 Answer(s)
  • User Avatar
    0
    compassinformatics17 created

    After much googling, I managed to track this down to a reported issue on github. It seems its related to the new project structure which means items in the Core project are not accessible from Application.Shared.

    https://github.com/aspnetboilerplate/aspnetboilerplate/issues/4620

    I hope it helps someone and saves them some searching to track down the issue.

    Regards, Barry.