Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
AutoMapper throws an error - how to figure out?
Message
De
12/05/2016 14:26:02
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Produits tierce partie
Versions des environnements
Environment:
C# 5.0
OS:
Windows 10
Database:
MS SQL Server
Divers
Thread ID:
01636216
Message ID:
01636251
Vues:
48
This message has been marked as a message which has helped to the initial question of the thread.
Read the documentation. It's a method on MapperConfiguration.

https://github.com/AutoMapper/AutoMapper/wiki/Configuration-validation

>In the API controller I tried adding this line
>
>
>AutoMapperConfig.Mapper.AssertConfigurationIsValid();
>
>but got this error:
>
>Severity Code Description Project File Line Suppression State
>Error CS1061 'IMapper' does not contain a definition for 'AssertConfigurationIsValid' and no extension method 'AssertConfigurationIsValid' accepting a first argument of type 'IMapper' could be found (are you missing a using directive or an assembly reference?) SysManager.Web D:\_Siriusware\Main\SysManager\SysManager.Web\Areas\Guests\Controllers\PassesApiController.cs 35 Active
>
>
>>>Hi everybody,
>>>
>>>We got that form working fine last time I tested (it was a while ago). Yesterday I tried to test it again (and I upgraded to the latest AutoMapper and prior to that my colleague also upgraded about a month or 2 ago) and I'm getting this error now:
>>>
>>>AutoMapper.AutoMapperMappingException was unhandled by user code
>>>  HResult=-2146233088
>>>  Message=Missing type map configuration or unsupported mapping.
>>>
>>>Mapping types:
>>>GstPass -> EditPassViewModel
>>>Siriusware.Models.GstPass -> SysManager.Web.Areas.Guests.Models.EditPassViewModel
>>>
>>>Destination path:
>>>EditPassViewModel
>>>
>>>Source value:
>>>Siriusware.Models.GstPass
>>>
>>>Both classes (GstPass and EditPassViewModel) are quite complex. I have the following in the AutoMapper.config
>>>
>>>
>>>  CreateMap<GstPass, EditPassViewModel>()
>>>                //.ForMember(dest => dest.LastUse,
>>>                //    opt => opt.ResolveUsing<TrimStringResolver>().FromMember(source => source.LastUse.Value.ToString()))
>>>             .ForMember(dest => dest.InHouseCardBalanceAndLimits, option => option.Ignore())
>>>             .ForMember(dest => dest.InHouseCardTransactions, option => option.Ignore())
>>>             .ForMember(dest => dest.BlReason,
>>>                    opt => opt.ResolveUsing<TrimStringResolver>().FromMember(source => source.BlReason.ToString()));
>>>
>>>I'm wondering what can I do to figure out why I'm getting this error which is new as that form used to work before.
>>>
>>>Thanks in advance.
>>
>>Have you tried AssertConfigurationIsValid() ?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform