question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update to AutoMapper 7.0.0 causes exceptions

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
TylerCarlson1commented, Jun 7, 2018

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

1reaction
YZahringercommented, Jun 23, 2018

When did you plan to release the new version?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Facing mapping exceptions after upgrading AutoMapper ...
With version 7.0.0 my application on Android and iOS was working fine. I have updated AutoMapper version to 9.0.0 and now it throws ......
Read more >
Is anyone else having issues with AutoMapper and .Net 7?
I just know that version 11 of AutoMapper added a change which can cause this exception. But I assume you use latest release...
Read more >
Nuget Packages are not found in repo
Failed to download package 'AutoMapper.Extensions.Microsoft.DependencyInjection.7.0.0' from 'https://our.nexus.registry/repository/nuget-group/AutoMapper.
Read more >
Getting Started Guide — AutoMapper documentation
AutoMapper will ignore null reference exceptions when mapping your source to your target. This is by design. If you don't like this approach,...
Read more >
The reasons behind why I don't use AutoMapper.
I observed that AutoMapper is somehow swallowing exception that occurs during the mapping. These reasons makes debugging very hard.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found