将AutoMapper.Extensions.Microsoft.DependencyInjection从5.0.1升级到6会在MapperConfiguration中引发异常

时间:2018-12-13 17:07:12

标签: automapper asp.net-core-2.2

我们有一个ASP.NET Core 2.2应用程序,我们刚刚从5.0.1迁移到了AutoMapper.Extensions.Microsoft.DependencyInjection版本6。 解决了与替换ResolveUsing和UseValue的用法以使用MapFrom有关的重大更改之后,无论是运行应用程序还是ConfigurationIsValid测试,它都会在MapperConfiguration初始化中引发“序列不包含任何元素”。 注入配置文件的方式没有发生任何变化,我们使用的是到目前为止一直使用的标准服务注入:

// In startup.cs
services.AddAutoMapper();

 // In mapper unit test
 var assembly = Assembly.GetAssembly(typeof(Startup));
 var mapperConfiguration = new MapperConfiguration(config => 
 config.AddProfiles(assembly)); <- This throws exception now
 mapperConfiguration.AssertConfigurationIsValid();

0 个答案:

没有答案