AutoMapper/AutoMapper — Issue #161: Feature Request: Add documentation to indicate that AutoMapper may need to be excluded from ilmerge's "Internalize" option if merging and obfuscating assemblies otherwise you would get errors like the following...
Author: icnocop
Created: 2011-12-21 03:10:00+00:00
State: open

Thank you for AutoMapper!

I'd like to request that documentation be added to indicate that AutoMapper may need to be excluded from ilmerge's "Internalize" option if merging and obfuscating assemblies otherwise you would get errors like the following:
AutoMapper.AutoMapperMappingException: Trying to map TypeA to TypeB.
Using mapping configuration for TypeA to TypeB
Exception of type 'AutoMapper.AutoMapperMappingException' was thrown. ---> AutoMapper.AutoMapperMappingException: Trying to map SubTypeA to SubTypeB.
Using mapping configuration for SubTypeA to SubTypeB
Destination property: PropertyA
Exception of type 'AutoMapper.AutoMapperMappingException' was thrown. ---> AutoMapper.AutoMapperMappingException: Trying to map SubTypeA to SubTypeB.
Using mapping configuration for SubTypeA to SubTypeB
Destination property: PropertyA
Exception of type 'AutoMapper.AutoMapperMappingException' was thrown. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: meth
at System.Reflection.Emit.ILGenerator.Emit(OpCode opcode, MethodInfo meth)
at Castle.DynamicProxy.Generators.Emitters.SimpleAST.MethodInvocationExpression.Emit(IMemberEmitter , ILGenerator )
at Castle.DynamicProxy.Generators.Emitters.SimpleAST.ExpressionStatement.Emit(IMemberEmitter , ILGenerator )
at Castle.DynamicProxy.Generators.Emitters.CodeBuilders.AbstractCodeBuilder.Generate(IMemberEmitter , ILGenerator )
at Castle.DynamicProxy.Generators.Emitters.MethodEmitter.Generate()
at Castle.DynamicProxy.Generators.Emitters.AbstractTypeEmitter.EnsureBuildersAreInAValidState()
at Castle.DynamicProxy.Generators.Emitters.AbstractTypeEmitter.BuildType()
at Castle.DynamicProxy.Contributors.InterfaceProxyWithoutTargetContributor.(MetaMethod , ClassEmitter , ProxyGenerationOptions )
at Castle.DynamicProxy.Contributors.InterfaceProxyWithoutTargetContributor.GetMethodGenerator(MetaMethod , ClassEmitter , ProxyGenerationOptions , CreateMethodDelegate )
at Castle.DynamicProxy.Contributors.CompositeTypeContributor.(MetaMethod , ClassEmitter , ProxyGenerationOptions , CreateMethodDelegate )
at Castle.DynamicProxy.Contributors.CompositeTypeContributor.(ClassEmitter , MetaProperty , ProxyGenerationOptions )
at Castle.DynamicProxy.Contributors.CompositeTypeContributor.Generate(ClassEmitter , ProxyGenerationOptions )
at Castle.DynamicProxy.Generators.InterfaceProxyWithoutTargetGenerator.GenerateType(String , Type , Type[] , INamingScope )
at Castle.DynamicProxy.Generators.InterfaceProxyWithTargetGenerator.GenerateCode(Type , Type[] , ProxyGenerationOptions )
at Castle.DynamicProxy.DefaultProxyBuilder.CreateInterfaceProxyTypeWithoutTarget(Type , Type[] , ProxyGenerationOptions )
at Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyTypeWithoutTarget(Type , Type[] , ProxyGenerationOptions )
at Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithoutTarget(Type , Type[] , ProxyGenerationOptions , IInterceptor[] )
at Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithoutTarget(Type , IInterceptor )
at AutoMapper.MappingEngine.853blrbljkd9jxnfggg2zw77zfpegnqu ?(ResolutionContext )
at AutoMapper.Mappers.TypeMapObjectMapperRegistry.. ?(ResolutionContext , IMappingEngineRunner )
at AutoMapper.Mappers.TypeMapObjectMapperRegistry..Map(ResolutionContext , IMappingEngineRunner )
at AutoMapper.Mappers.TypeMapMapper.Map(ResolutionContext , IMappingEngineRunner )
at AutoMapper.MappingEngine.853blrbljkd9jxnfggg2zw77zfpegnqu ?(ResolutionContext )
--- End of inner exception stack trace ---
at AutoMapper.MappingEngine.853blrbljkd9jxnfggg2zw77zfpegnqu ?(ResolutionContext )
at AutoMapper.Mappers.TypeMapObjectMapperRegistry..(ResolutionContext , IMappingEngineRunner , Object , PropertyMap )
--- End of inner exception stack trace ---
at AutoMapper.Mappers.TypeMapObjectMapperRegistry..(ResolutionContext , IMappingEngineRunner , Object , PropertyMap )
at AutoMapper.Mappers.TypeMapObjectMapperRegistry..Map(ResolutionContext , IMappingEngineRunner )
at AutoMapper.Mappers.TypeMapMapper.Map(ResolutionContext , IMappingEngineRunner )
at AutoMapper.MappingEngine.853blrbljkd9jxnfggg2zw77zfpegnqu ?(ResolutionContext )
--- End of inner exception stack trace ---
at AutoMapper.MappingEngine.853blrbljkd9jxnfggg2zw77zfpegnqu ?(ResolutionContext )
at AutoMapper.MappingEngine.Map(Object , Type , Type )
at AutoMapper.MappingEngine.Map[TSource,TDestination](TSource )
at AutoMapper.Mapper.Map[TSource,TDestination](TSource )
at MyCode

It took me a while to figure out and this work-around solved my issue! :)