Error: No parameterless constructor for AutoMapperConfigurationAutoMapper依賴注入參數
我使用的NuGet包automapper DI
public class AutoMapperConfiguration : Profile
{
private readonly ICloudStorage _cloudStorage;
public AutoMapperConfiguration(ICloudStorage cloudStorage)
{
_cloudStorage = cloudStorage;
// Do mapping here
}
}
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<ICloudStorage, AzureStorage>();
services.AddAutoMapper(); // Errors here
}
如何使用帶參數的automapper DI?
也許[這](https://stackoverflow.com/a/40275196/6583901)幫助 – NtFreX
@ Dr.Fre不允許在automapper構造 –
@MartinDawson是正確的參數。您只能注入自定義解析器和轉換器。 – efredin