I have Task.WhenAll(tasks), and each task uses AutoMapper's ValueResolver which has dependency, resolved via DI.
public AutoMapperRegistry()
{
ForSingletonOf<MapperConfiguration>().Use("Build AutoMapper config", ctx =>
{
var profiles = ctx.GetAllInstances<Profile>();
var config = new MapperConfiguration(cfg =>
{
cfg.AllowNullCollections = true;
foreach (var profile in profiles)
{
cfg.AddProfile(profile);
}
});
return config;
});
For<IMapper>().Use(ctx => ctx.GetInstance<MapperConfiguration>().CreateMapper(ctx.GetInstance));
}
When AutoMapper creates ValueResolver instance, same dependency added to dictionary more than once:
System.ArgumentException: An item with the same key has already been added.
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at StructureMap.SessionCache.GetDefault(Type pluginType, IPipelineGraph pipelineGraph)
at AutoMapper.MappingOperationOptions`2.CreateInstance[T]()
Looks like expcetion from https://github.com/structuremap/structuremap/blob/master/src/StructureMap/SessionCache.cs#L77
I have
Task.WhenAll(tasks), and each task uses AutoMapper's ValueResolver which has dependency, resolved via DI.When AutoMapper creates ValueResolver instance, same dependency added to dictionary more than once:
Looks like expcetion from https://github.com/structuremap/structuremap/blob/master/src/StructureMap/SessionCache.cs#L77