Automapper attributes을 살펴본 후 this question에 응답하려고 했으므로 동작을 재현 할 빠른 콘솔 응용 프로그램을 만들었습니다. 나는 GitHub의 문서에서 첫 번째 예에서 (사본 - 붙여 넣기) 클래스를 추가 한 :ConsoleApplication.exe에서 'System.TypeInitializationException'유형의 처리되지 않은 예외가 발생했습니다 - Automapper
[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; }
}
그리고 주에서 같은 문장을 추가 :
typeof(Program).Assembly.MapTypes(); //this throws exception
var person = new Person { FirstName = "John", LastName = "Lackey" };
var customer = AutoMapper.Mapper.Map<Customer>(person);
하지만 코드의 첫 줄에
본관MapTypes
방법 TypeInitializationException가 슬로우
유형의 예외를 호출했을 때
유형의 처리되지 않은 예외 '를 System.TypeInitializ ationException '는 ConsoleApplication.exe
에 추가 정보를 발생하기위한 형식 이니셜'AutoMapper.Attributes.Extensions '는 예외가 발생했습니다.
설명서의 모든 지침을 준수했기 때문에이 예외가 throw되는 이유는 무엇입니까?
내부 예외입니다 :
는{ "순서가 일치하는 요소를 포함하지 않는다"}
참고 :
내가 AutoMapper 버전 5.1.1 및 AutoMapper.Attributes 버전 1.0을 사용하고 있습니다 .20.
Attributes.Extensions
에 반사를 통해 조회되는 변경 것 같다? – Georg@Georg는 같은 문제가있는 것처럼 보이지만 여전히 작동하지 않는 이유를 이해할 수 없습니다. – meJustAndrew