I am working on a Xamarin project that is using AutoMapper. When linking is set to "Link Framework SDKs Only" I get the following error when initializing the maps
System.ArgumentNullException: Value cannot be null. Parameter name: method
The exception is not much to go on and neither is the callstack
AutoMapper.Mappers.ConvertMapper.MapExpression
AutoMapper.Execution.TypeMapPlanBuilder.ObjectMapperExpression
AutoMapper.Execution.TypeMapPlanBuilder.MapExpression
AutoMapper.Mappers.NullableSourceMapper.MapExpression
AutoMapper.Execution.TypeMapPlanBuilder.ObjectMapperExpression
AutoMapper.Execution.TypeMapPlanBuilder.MapExpression
AutoMapper.Execution.TypeMapPlanBuilder.MapExpression
AutoMapper.Execution.TypeMapPlanBuilder.CreatePropertyMapFunc
AutoMapper.Execution.TypeMapPlanBuilder.CreatePropertyMapFunc
AutoMapper.Execution.TypeMapPlanBuilder.TryPropertyMap
AutoMapper.Execution.TypeMapPlanBuilder.CreateAssignmentFunc
AutoMapper.Execution.TypeMapPlanBuilder.CreateMapperLambda
AutoMapper.TypeMap.Seal AutoMapper.MapperConfiguration.Seal
AutoMapper.MapperConfiguration..ctor
AutoMapper.MapperConfiguration..ctor AutoMapper.Mapper.Initialize
The initial reading of that suggests that the Linker is simply removing some properties or indeed methods from some class we are using.
However, after commenting out most of the mappings and then reintroducing them one at a time I find that this class is currently causing the error.
[Preserve]
internal class ItemBase : CareRecordItemBase
{
[Preserve]
public string Topic { get; set; }
[Preserve]
public string InPractice { get; set; }
[Preserve]
public string PrivateVal { get; set; }
}
If I comment out the InPractice
property the exception does not get thrown. This makes no sense to me. Can anyone explain why this might be a problem?
Are there better ways of diagnosing these issues?
Based on Pat's Answer:
LinkDescription.xml
, you can name it anything you want.<linker>
<assembly fullname="mscorlib">
<type fullname="System.Convert" preserve="All" />
</assembly>
</linker>
LinkDescription
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With