I went through several issues but can't get it right.
When trying to use AutoMapper 7.0, I'm getting a Mapper not initialized
exception - though I think that my issue is not related to AutoMapper but to the way I try to register a service to my WCF.
I followed this article and created a ServiceBehavior for my AutoMapper:
public sealed class AutomapServiceBehavior : Attribute, IServiceBehavior
{
public AutomapServiceBehavior()
{
}
public void AddBindingParameters(ServiceDescription serviceDescription, ServiceHostBase serviceHostBase,
Collection<ServiceEndpoint> endpoints, BindingParameterCollection bindingParameters)
{
AutomapBootstrap.InitializeMap();
}
public void ApplyDispatchBehavior(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase)
{
}
public void Validate(ServiceDescription serviceDescription, System.ServiceModel.ServiceHostBase serviceHostBase)
{
}
}
Then added a breakpoint to AutomapBootstrap.InitializeMap() (which looks like this):
public class AutomapBootstrap
{
public static void InitializeMap()
{
//BREAKPOINT ADDED HERE
var config = new MapperConfiguration(cfg =>
cfg.CreateMap<ClassA, ClassB>()
);
var mapper = new Mapper(config);
}
}
I thought that the app should stop at my breakpoint during startup, but it doesn't. What am I missing?