覆盖void Automapper Profile中的Configure(),给出编译错误"AutoMapperBootstrap.Configure()":找不到合适的方法来覆盖"

Rit*_*jak 7 profile automapper

public class AutoMapperBootstrap : AutoMapper.Profile
{
    protected override void Configure()
    {
        //ReplaceMemberName("Z", "A");
        //CreateMap<Source, Destination>(); 
    }
    public override string ProfileName
    {
        get { return this.GetType().Name; }
    }
}
Run Code Online (Sandbox Code Playgroud)

我在我的MVC应用程序的App_Start文件夹中有这个AutoMapperBootstrap类.

在"configure"方法中,它给出了编译器错误 - "No Suitable method to override",我得到的是configure方法的错误而不是ProfileName的错误

我在自定义Automapper配置文件中的StackOverflow覆盖配置文件的配置方法中看到了很多示例.

但是为什么我得到这个编译错误.

请让我知道我犯的错误是什么?

或者是最新版本的Automapper没有覆盖此Configure方法.

注意:我已将Nuget的最新Automapper版本6.1.1.0下载到我的应用程序中.

Mat*_*per 14

较新版本的AutoMapper 具有不同的设置配置文件的方法.我正在使用此处描述的方法在.net项目中的类库中设置自动化.

namespace Project.Helpers
{
    public class NewMapperProfile : Profile
    {
        public NewMapperProfile()
        {
            CreateMap<ClassA, ClassB>();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

  • 所以,我确实发现更新版本的AutoMapper不再使用"覆盖配置"方法.此外,我测试了上面创建配置文件的方法,它的工作原理.我希望这有帮助! (2认同)