我正在尝试将Automapper 3.2.1与Unity 3.0.1304.1注册。我已经尝试了StackOverflow上的常规注册答案,但都没有成功。你有什么线索可以正确地将最新版本的Automapper与Unity注册吗?在最近的版本中是否有任何更改?以下是代码和异常:
像这样注册:
container.RegisterType<ConfigurationStore, ConfigurationStore>(new ContainerControlledLifetimeManager(), new InjectionConstructor(typeof(ITypeMapFactory), MapperRegistry.Mappers));
container.RegisterType<IConfigurationProvider, ConfigurationStore>();
container.RegisterType<IConfiguration, ConfigurationStore>();
container.RegisterType<IMappingEngine, MappingEngine>();
container.RegisterType<ITypeMapFactory, TypeMapFactory>();
接着我收到了以下错误:
IDictionary`2 类型没有可访问的构造函数。
此时,正在解决这个问题:
Resolving AutoMapper.MappingEngine,(none) (mapped from AutoMapper.IMappingEngine, (none))
Resolving parameter "objectMapperCache" of constructor AutoMapper.MappingEngine(AutoMapper.IConfigurationProvider configurationProvider, AutoMapper.Internal.IDictionary`2[[AutoMapper.Impl.TypePair, AutoMapper, Version=3.2.1.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005],[AutoMapper.IObjectMapper, AutoMapper, Version=3.2.1.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005]] objectMapperCache, System.Func`2[[System.Type, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] serviceCtor)
Resolving AutoMapper.Internal.IDictionary`2[AutoMapper.Impl.TypePair,AutoMapper.IObjectMapper],(none)