Skip to content

Instantly share code, notes, and snippets.

@iulian0512
Last active September 26, 2019 15:23
Show Gist options
  • Save iulian0512/b8a36633eca9dfa91a88fd94ae2dbac8 to your computer and use it in GitHub Desktop.
Save iulian0512/b8a36633eca9dfa91a88fd94ae2dbac8 to your computer and use it in GitHub Desktop.
automapper crash .net 4.7.2
using AutoMapper;
using AutoMapper.Data;
using System;
using System.Collections.Generic;
using System.Data;
namespace automappercrash
{
public interface dummyinterface
{
string test();
}
public class dummy1
{
public string name { get; set; }
public dummyinterface tintf { get; set; }
}
public class dummy2
{
public string aaa { get; set; }
public dummy1 test { get; set; }
}
class Program
{
static void Main(string[] args)
{
var mapper = new MapperConfiguration(cfg =>
{
//this causes the crash, without it this example runs without any exceptions
cfg.AddDataReaderMapping();
cfg.CreateMap<IDataRecord, dummy2>()
.ForMember(dto => dto.aaa, o => o.MapFrom(a => a["test"]))
.ForAllOtherMembers(a => a.Ignore());
});
}
}
}
System.ArgumentNullException: Value cannot be null.
Parameter name: con
at System.Reflection.Emit.DynamicILGenerator.Emit(OpCode opcode, ConstructorInfo con)
at AutoMapper.Data.Configuration.Conventions.DataRecordMemberConfiguration.EmitPropertyMapping(ILGenerator il, Type destType, Type destMemberType, String nameToSearch)
at AutoMapper.Data.Configuration.Conventions.DataRecordMemberConfiguration.EmitPropertyMapping(ILGenerator il, Type destType, Type destMemberType, String nameToSearch)
at AutoMapper.Data.Configuration.Conventions.DataRecordMemberConfiguration.MapDestinationPropertyToSource(ProfileMap options, TypeDetails sourceType, Type destType, Type destMemberType, String nameToSearch, LinkedList`1 resolvers, IMemberConfiguration parent)
at AutoMapper.Configuration.Conventions.MemberConfiguration.MapDestinationPropertyToSource(ProfileMap options, TypeDetails sourceType, Type destType, Type destMemberType, String nameToSearch, LinkedList`1 resolvers) in C:\projects\automapper\src\AutoMapper\Configuration\Conventions\MemberConfiguration.cs:line 54
at AutoMapper.ProfileMap.<>c__DisplayClass70_0.<MapDestinationPropertyToSource>b__0(IMemberConfiguration _) in C:\projects\automapper\src\AutoMapper\ProfileMap.cs:line 266
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
at AutoMapper.ProfileMap.MapDestinationPropertyToSource(TypeDetails sourceTypeInfo, Type destType, Type destMemberType, String destMemberInfo, LinkedList`1 members) in C:\projects\automapper\src\AutoMapper\ProfileMap.cs:line 266
at AutoMapper.TypeMapFactory.CreateTypeMap(Type sourceType, Type destinationType, ProfileMap options) in C:\projects\automapper\src\AutoMapper\TypeMapFactory.cs:line 22
at AutoMapper.ProfileMap.BuildTypeMap(IConfigurationProvider configurationProvider, ITypeMapConfiguration config) in C:\projects\automapper\src\AutoMapper\ProfileMap.cs:line 121
at AutoMapper.ProfileMap.Register(IConfigurationProvider configurationProvider) in C:\projects\automapper\src\AutoMapper\ProfileMap.cs:line 98
at AutoMapper.MapperConfiguration.Seal() in C:\projects\automapper\src\AutoMapper\MapperConfiguration.cs:line 298
at AutoMapper.MapperConfiguration..ctor(MapperConfigurationExpression configurationExpression) in C:\projects\automapper\src\AutoMapper\MapperConfiguration.cs:line 55
at AutoMapper.MapperConfiguration..ctor(Action`1 configure) in C:\projects\automapper\src\AutoMapper\MapperConfiguration.cs:line 60
at automappercrash.Program.Main(String[] args) in C:\Users\iulian\Documents\Visual Studio 2017\Projects\automappercrash\Program.cs:line 31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment