Strange String to Boolean mapping behavior

By mistake, someone from my project wrote the following sentence in the automapper profile:

Mapper.CreateMap<Appointment, AppointmentModel>()
    .ForMember(x => x.DeclineStart, o => o.MapFrom(x => x.DeclineStart.ToString()))

      

Where DeclineStart

is a property of the object and model classes.

public class Appointment
{
   public bool DeclineStart { get; set; }
}

public class AppointmentModel
{
   public bool DeclineStart { get; set; }
}

      

I know that in this case there is no need to create any display rules for this property.

To my surprise, this mapping (from String

to Boolean

) works.

But when we published our application to the Azure cloud service, this code starts throwing AutoMapperMappingException

, which shows that:

Missing type map configuration or unsupported mapping.
Mapping types:String -> Boolean (System.String -> System.Boolean)
Destination path: AppointmentModel.DeclineStartBackfill.DeclineStartBackfill
Source value:False

      

How is it possible that the same code works locally but doesn't work on Azure?

Thanks in advance!


Azure Configuration: Windows Server 2012 R2 / .NET Framework 4.5.1

Local computer configuration: Windows 7 / .NET Framework 4.5.2

Automapper version: 3.1.0

+3


source to share


1 answer


Do all of your AutoMapper assemblies build, including the AutoMapper.Net4.dll assembly? This optional assembly has extensions available in .NET 4 that are not available elsewhere, including type converters.

You have two options, manually link to something inside the .NET4.dll assembly:



public static class LinkerHelper {
    public static object BecauseAzureDeploymentsAreDumb() {
        var foo = typeof(HashSetMapper);
        return foo;
    }
}

      

Or update to the latest beta of AutoMapper where I've merged the platform specific assemblies.

+1


source







All Articles