AutoMapper Mapper.Configuration.AssertConfigurationIsValid() проходит, но все равно ошибка времени выполнения
[Контекст - это веб-приложение ASP.NET MVC]. Недавно я обновил свои ссылки на AutoMapper до 4.2.1, и у меня все это подходит. Это не сломало мое производственное приложение, и клиенты не довольны. Надеюсь, кто-то может помочь.
Я исправил все ошибки, возвращенные в результате Mapper.AssertConfigurationIsValid();
так что теперь ошибок нет. Тем не менее, во время очереди, когда я звоню Mapper.Map<ConsumeInventoryViewModel>(pullListDetailViewModel);
Я получаю ошибку:
[AutoMapperMappingException: Missing type map configuration or unsupported mapping.
Mapping types:
PullListDetailViewModel -> ConsumeInventoryViewModel
OTIS.AppServ.InventoryMgmt.ViewModels.PullListDetailViewModel -> OTIS.AppServ.InventoryMgmt.ViewModels.ConsumeInventoryViewModel
Destination path:
ConsumeInventoryViewModel
Source value:
OTIS.AppServ.InventoryMgmt.ViewModels.PullListDetailViewModel]
Важно то, что я получаю эту ошибку для ВСЕХ отображений, которые у меня есть, и вызываю, а не только одно... ну, я должен сказать, для нескольких... Я не пробовал все, но для тех, которые я вызвал, это создает ошибка.
Вот некоторые подробности:
Модели:
public class AutoPullViewModel
{
public bool autoLocateOnPull { get; set; }
}
public class PullListDetailViewModel : AutoPullViewModel
{
public int? AllocatedInventoryId { get; set; }
[Display(Name = "Work Release")]
public int WorkReleaseHeaderId { get; set; }
public OrderHeader.OrderTypes OrderTypeEnum { get; set; }
[Display(Name = "Order/Job")]
public int? OrderId { get; set; }
[Display(Name = "Part Nbr")]
public int? OrderDetailId { get; set; }
[Display(Name = "Work Order")]
public int? WorkOrderId { get; set; }
public int? WorkOrderDetailId { get; set; }
public bool IsInventoriedItem { get; set; }
[Display(Name = "Container")]
public int? InventoryContainerHeaderId { get; set; }
public string OriginalContainerLocationBarcode { get; set; }
public int? LocationInventoryId {get; set;}
public string RequiredLocationBarcode { get; set; }
[Display(Name = "Location")]
public string LocationDescription { get; set; }
public int ItemId { get; set; }
public string SKU { get; set; }
public string RequiredItemBarcode { get; set; }
[Display(Name = "Item/Material")]
public string ItemDescription { get; set; }
public string ItemImageURL { get; set; }
[Display(Name = "Qty")]
[DisplayFormat(DataFormatString = "{0:N1}")]
public decimal RequiredQuantity { get; set; }
public string QuantityDescription { get; set; }
public string QuantityUOM { get; set; }
}
//Direct user to location for selected material
public class ConsumeInventoryViewModel : PullListDetailViewModel
{
[Display(Name = "Scan Location")]
public string ScannedLocationBarcode { get; set; }
[Display(Name = "Scan Item")]
public string ScannedItemBarcode { get; set; }
[Display(Name = "Scan Container")]
public int? ScannedContainerId { get; set; }
[Required]
[Display(Name = "Act Qty")]
[UIHint("TextBoxFor_75w")]
public decimal? ConfirmedQty { get; set; }
[Display(Name = "Only Remnants?")]
public bool Remnant { get; set; }
}
Звонок по настройке в Global.asax Application_Start
protected void Application_Start()
{
...
AutoMapperConfiguration.Configure();
}
Статический конфигуратор:
public static class AutoMapperConfiguration
{
public static void Configure()
{
//see https://github.com/AutoMapper/AutoMapper/wiki/Configuration
Mapper.Initialize(cfg =>
{
cfg.CreateMap<PullListDetailViewModel, ConsumeInventoryViewModel>()
.ForMember(dest => dest.ScannedLocationBarcode, option => option.Ignore())
.ForMember(dest => dest.ScannedItemBarcode, option => option.Ignore())
.ForMember(dest => dest.ScannedContainerId, option => option.Ignore())
.ForMember(dest => dest.ConfirmedQty, option => option.Ignore())
.ForMember(dest => dest.Remnant, option => option.Ignore())
;
});
Mapper.AssertConfigurationIsValid();
}
}
И, наконец, вызов времени выполнения на карту:
var consumeInventoryViewModel = Mapper.Map<ConsumeInventoryViewModel>(pullListDetailViewModel);
Как и в этом другом посте, после перезапуска веб-сайта в IIS (и я могу отладить и убедиться, что конфигурация и проверка выполняются, первый вызов карты времени выполнения работает, но все последующие сбои.
У кого-нибудь есть какие-нибудь указатели / идеи?