gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 17:35:52 26 4
gpt4 key购买 nike

我已通过 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<br/>
AutoMapper.Mapper.get_ConfigurationProvider() +34<br/>
AutoMapper.Mapper.get_Configuration() +28<br/>
AutoMapper.Mapper.Initialize(Action
1 action) +51
AIMS.Mappers.AutoMapperConfig.Initialize() in c:\Projects\AIMS\AIMS\Mappers\AutoMapperConfig.cs:9
AIMS.MvcApplication.Application_Start() in c:\Projects\AIMS\AIMS\Global.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 包含修复程序。结果证明支持可移植类库需要更多的工作:)

关于c# - 使用 AutoMapper 时,此平台不支持 IDictionaryFactory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19388490/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com