加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 当使用AutoMapper时,此平台不支持IDictionaryFactory

发布时间:2020-12-15 03:55:31 所属栏目:百科 来源:网络整理
导读:我已经通过NuGet安装了AutoMapper 3.1.0-ci1027到MVC5网站.我使用 Owain Wraggs’ Blog作为我的指南来帮助我. 我的配置文件如下所示: public static class AutoMapperConfig{ public static void Initialize() { Mapper.Initialize(x = { x.AddProfileDomai
我已经通过NuGet安装了AutoMapper 3.1.0-ci1027到MVC5网站.我使用 Owain Wraggs’ Blog作为我的指南来帮助我.

我的配置文件如下所示:

public static class AutoMapperConfig
{
    public static void Initialize()
    {
        Mapper.Initialize(x =>
        {
            x.AddProfile<DomainToViewModelMappers>();
            x.AddProfile<ViewModelToDomainMappers>();
        });
    }
}

我正在Global.asax.cs.Application_Start()中调用Initialize()方法:

AutoMapperConfig.Initialize();

但是,当我运行应用程序时,它会在Mapper.Initialize()中崩溃.即使我不在其中包含任何代码,也会发生这种情况.如果我将此行注释出来,代码运行正常,但当然,我没有使用AutoMapper连接我的对象.

我看到的错误如下:

[PlatformNotSupportedException: This type is not supported on this
platform IDictionaryFactory]
AutoMapper.Internal.PlatformAdapter.Resolve(Boolean throwIfNotFound)
+320 AutoMapper.TypeMapFactory..cctor() +46

[TypeInitializationException: The type initializer for
‘AutoMapper.TypeMapFactory’ threw an exception.]
AutoMapper.TypeMapFactory..ctor() +0
AutoMapper.Mapper.<.cctor>b__0() +55
AutoMapper.Internal.LazyImpl1.get_Value() +79
AutoMapper.Mapper.get_ConfigurationProvider() +34
AutoMapper.Mapper.get_Configuration() +28
AutoMapper.Mapper.Initialize(Action
1 action) +51
AIMS.Mappers.AutoMapperConfig.Initialize() in
c:ProjectsAIMSAIMSMappersAutoMapperConfig.cs:9
AIMS.MvcApplication.Application_Start() in
c:ProjectsAIMSAIMSGlobal.asax.cs:25

[HttpException (0x80004005): The type initializer for
‘AutoMapper.TypeMapFactory’ threw an exception.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext
context,HttpApplication app) +9936841
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr
appContext,HttpContext context,MethodInfo[] handlers) +118
System.Web.HttpApplication.InitSpecial(HttpApplicationState state,
MethodInfo[] handlers,IntPtr appContext,HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr
appContext,HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr
appContext) +296

[HttpException (0x80004005): The type initializer for
‘AutoMapper.TypeMapFactory’ threw an exception.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9915380
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)
+101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr,HttpContext context) +254

对我失踪的任何想法将不胜感激.

解决方法

这是AutoMapper中的一个错误,版本3.1.0-ci1032包含修复.结果支持便携式类库需要更多的工作:)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读