简体   繁体   English

Windows 8.1 Unified项目中的自动映射器启动异常

[英]Automapper starting exception in Windows 8.1 Unified project

I have a cross-platform project, using mvvmcross and stuff. 我有一个跨平台的项目,使用mvvmcross和东西。 Right now, solution consists of Core and Windows Phone projects. 目前,解决方案由Core和Windows Phone项目组成。

Core contains AutoMapper reference, and WP project contains AutoMapper and AutoMapper.WPA references. 核心包含AutoMapper参考,而WP项目包含AutoMapper和AutoMapper.WPA参考。

Application works fine in most cases, but sometimes it throws exceptions like Could not load file or assembly 'AutoMapper.Net4' . 应用程序在大多数情况下都能正常运行,但有时会引发诸如Could not load file or assembly 'AutoMapper.Net4'异常。 How can i explain to that stupid AutoMapper to use AutoMapper.WPA, which is already referenced to the project? 我如何向那个愚蠢的AutoMapper解释使用AutoMapper.WPA,该项目已被引用? I'm using it as 我正在使用它

public static class AutoMapperConfig
{
    static AutoMapperConfig()
    {
        Mapper.CreateMap<MyDbModel, MyDto>();

        Mapper.AddProfile<MyProfile>();

        // Other mappings stuff            
    }

    public static void Initialize()
    {
        Mapper.AssertConfigurationIsValid();
    }
}

and i'm calling it from Setup, which is in Shared project, 我从共享项目中的安装程序中调用它,

public class Setup : MvxWindowsSetup
{
    public Setup(Frame rootFrame) : base(rootFrame)
    {
        AutoMapperConfig.Initialize();
    }
    *** 
}

Is this happening while debugging? 这是在调试时发生的吗? If so, you're likely showing all exceptions, instead of just uncaught exceptions. 如果是这样,您很可能会显示所有异常,而不仅仅是未捕获的异常。 Switch to uncaught-exceptions and you should be good. 切换到未捕获的异常,您应该会很好。

The 4.0 release of stupid AutoMapper is moving away from platform-specific extension assemblies and instead is doing compiler directives to compile into a single assembly per platform. 愚蠢的AutoMapper 4.0版本不再使用特定于平台的扩展程序集,而是在执行编译器指令以将其编译为每个平台的单个程序集。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM