Automapper starting exception in Windows 8.1 Unified project

172 views Asked by At

I have a cross-platform project, using mvvmcross and stuff. Right now, solution consists of Core and Windows Phone projects.

Core contains AutoMapper reference, and WP project contains AutoMapper and AutoMapper.WPA references.

Application works fine in most cases, but sometimes it throws exceptions like 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? 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();
    }
    *** 
}
1

There are 1 answers

2
Jimmy Bogard On BEST ANSWER

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.