AutoMapper / AutoMapper.Collection

AutoMapper support for updating existing collections by equivalency
MIT License
245 stars 59 forks source link

Update to AutoMapper 7.0.0 causes exceptions #91

Closed slubowsky closed 6 years ago

slubowsky commented 6 years ago

Mapping that works as expected in 6.2.2 and earlier fails with a MissingMethodException in 7.0.0

AutoMapper.AutoMapperMappingException
  HResult=0x80131500
  Message=Error mapping types.
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

Inner Exception 1:
MissingMethodException: Method not found: 'System.__Canon AutoMapper.IRuntimeMapper.Map(System.__Canon, System.__Canon, AutoMapper.ResolutionContext)'.

Inner exception is:

{System.MissingMethodException: Method not found: 'System.__Canon AutoMapper.IRuntimeMapper.Map(System.__Canon, System.__Canon, AutoMapper.ResolutionContext)'.
   at AutoMapper.Mappers.EquivalentExpressionAddRemoveCollectionMapper.Map[TSource,TSourceItem,TDestination,TDestinationItem](TSource source, TDestination destination, ResolutionContext context, IEquivalentComparer`2 _equivalentComparer)
   at lambda_method(Closure , UpdateViewModel , Model, ResolutionContext )}

Stack Trace " at lambda_method(Closure , UpdateViewModel , Model, ResolutionContext )\r\n at Controller.Map[TA,TB](TA source, TB destination) in D:\\dev\\Controller.cs:line 63"

I have tried to determine the cause but have been unable to do so.

My mapping looks like this:

CreateMap<UpdateViewModel, Model>(MemberList.Source)
                .ForSourceMember(x => x.LastName, opt => opt.Ignore())
                ....

where I have ignored every single source member (including the one that shows up as PropertyMap in the exception - it happens to be a collection like many other properties in my code that are succesfully mapping) and still get it - despite every single member being set to ignore.

This is the only mapping - of dozens - that is causing a problem, and again there is no issue before upgrading to version 7.0.0

I had originally opened this issue in Automapper https://github.com/AutoMapper/AutoMapper/issues/2666 but issue was closed and it was recommended it be opened here instead

Perhaps this is covered by https://github.com/AutoMapper/AutoMapper.Collection/issues/88?

TylerCarlson1 commented 6 years ago

Try the MyGet for the 7.0.0 fix. Just use Automapper.Collections and allow pre-releases

slubowsky commented 6 years ago

Yes! It works. OK then, Ill just wait for the update. Thanks!

YZahringer commented 6 years ago

When did you plan to release the new version?

TylerCarlson1 commented 6 years ago

Until the other stuff was done but didn't hear back so, now it's released.

ubik commented 6 years ago

Hi. What versions have this issue fixed? When they will be available on nuget.org? PS I have updated to the latest release versions (7.0.1/3.1.4), but error still exist.

ristogod commented 6 years ago

Same. I saw the new version hoping this would fix the issue and sadly it hasn't.

TylerCarlson1 commented 6 years ago

As @Tasteful has pointed out to me, I forgot to merge all the changes into the master before building a release. It's building now but will be 4.0.0