为什么我在发布版本中出现此错误:此平台上不支持此类型INullableConverterFactory

时间:2014-10-05 18:14:14

标签: xamarin automapper

使用Xamarin XS v5.5,AutoMapper v3.2.1, 我在Release版本中得到了这个运行时错误(不在Debug中):
This type is not supported on this platform INullableConverterFactory

[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: 
  An exception was thrown by the type initializer for AutoMapper.Mappers.MapperRegistry --->
  System.TypeInitializationException: 
  An exception was thrown by the type initializer for AutoMapper.Mappers.EnumMapper --->
  System.PlatformNotSupportedException: This type is not supported on this platform INullableConverterFactory
[mono-rt]   at AutoMapper.Internal.PlatformAdapter.Resolve[INullableConverterFactory] (Boolean throwIfNotFound) [0x00000] in <filename unknown>:0 
[mono-rt]   at AutoMapper.Mappers.EnumMapper..cctor () [0x00000] in <filename unknown>:0 
[mono-rt]   --- End of inner exception stack trace ---
[mono-rt]   at AutoMapper.Mappers.MapperRegistry..cctor () [0x00000] in <filename unknown>:0 
[mono-rt]   --- End of inner exception stack trace ---
[mono-rt]   at AutoMapper.Mapper.Reset () [0x00000] in <filename unknown>:0 
[mono-rt]   at AutoMapper.Mapper.Initialize (System.Action`1 action) [0x00000] in <filename unknown>:0 
[mono-rt]   at MyApp.Android.MainActivity.ConfigMapper () [0x00000] in <filename unknown>:0 
[mono-rt]   at MyApp.Android.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x00000] in <filename unknown>:0 
[mono-rt]   at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) [0x00000] in <filename unknown>:0 
[mono-rt]   at (wrapper dynamic-method) object:3cc570cf-1f33-4513-b6e4-0e910820d0ba (intptr,intptr,intptr)

问题是什么?

1 个答案:

答案 0 :(得分:0)

链接器很可能是从AutoMapper程序集中删除该类型的。

通常RELEASE模式将链接器设置为SDK程序集或所有程序集,其中DEBUG不进行任何链接

点击此处查看如何修改链接内容 https://developer.xamarin.com/guides/cross-platform/advanced/custom_linking/

我有同样的例外,并将此人添加到修复中

<assembly fullname="AutoMapper">
   <type fullname="*INullableConverterFactory*" />
   <type fullname="*MappingExpression*" />
</assembly>