c# - An unhandled exception of type 'System.TypeInitializationException' occurred in ConsoleApplication.exe - Automapper -
after taking @ automapper attributes have tried answer this question have made quick console application reproduce behavior. have added (copy-pasted) classes in first example github documentation:
[mapsto(typeof(customer))] public class person { public string firstname { get; set; } public string lastname { get; set; } public string notes { get; set; } } public class customer { public string firstname { get; set; } public string lastname { get; set; } public string mycustomernotes { get; set; } }
and added same statements in main:
typeof(program).assembly.maptypes(); //this throws exception var person = new person { firstname = "john", lastname = "lackey" }; var customer = automapper.mapper.map<customer>(person);
but @ first line of code in main, when calling maptypes
method, exception of type typeinitializationexception thrown:
an unhandled exception of type 'system.typeinitializationexception' occurred in consoleapplication.exe
additional information: type initializer 'automapper.attributes.extensions' threw exception.
why exception thrown, since have followed instructions in documentation?
the inner exception is:
{"sequence contains no matching element"}
note:
i using automapper version 5.1.1 , automapper.attributes version 1.0.20.
looks using automapper 5, automapper.attributes
seems work version 4. tried version 4 , worked expected.
the problem seems method signature changed, looked via reflection in attributes.extensions
Comments
Post a Comment