Can anyone help me understand why this piece of code is throwing a NullReferenceException?
public static ScreenField ToDto(this FieldDefinition @from, IList<ScreenData> screenData)
{
if (@from == null)
return null;
var to = @from.ConvertTo<ScreenField>(); // <--- exception thrown here
...
return to;
}
The stack trace simply reads:
at ServiceStack.AutoMappingUtils.ChangeValueType(Object from, Type toType)
And I get the same result if I change the variable declaration to
var to = new ScreenField().PopulateWith(@from);