0

We have just upgraded from Automapper 4 to Automapper 10 (I have also repeated the same problem on Automapper 8.1.1)

I am unable to initialise the Automapper. T is a Profile class with CreateMap calls.

  var configuration = new MapperConfiguration(cfg =>
        {
            cfg.AddProfile<T>();
                
        });

After cfg.AddProfile it disappears into endless loops and never returns. It consumes 2GB of Memory before I pull the pin (this takes a few minutes). I've debugged into AutoMapper (this is from 8.1.1) and inside MapperConfiguration it calls a method Seal(); This is where it goes into loops.

The Profile class has 1200 calls to CreateMap

Any suggestions? Automapper 4 worked well, except for a few cases where it would randomly return a null reference exception trying to find a map.

This is .Net Framework 4.7.2 and Automapper 8.1.1 (and also with Automapper 10).

James Selleck
  • 199
  • 2
  • 9
  • 1
    A repro would help. Make a [gist](https://gist.github.com/lbargaoanu/9c7233441c3a3413cc2b9b9ebb5964a9) that we can execute and see fail. Start by making a sane configuration. You should have a reasonable number of maps in each profile. Once you do that, you should be able to further isolate the issue. – Lucian Bargaoanu Oct 05 '20 at 11:13
  • @LucianBargaoanu .. Thats part of the problem. Whats a reasonable number supposed to be? Automapper4 seemed to cope fine. How do I make a GIST that maps 600 different models to 600 dtos and also both ways.. to demonstrate my problem? Thanks in advance. – James Selleck Oct 05 '20 at 11:48
  • 1
    By isolating the problem, of course. I guess it's debatable what's reasonable, but 1200 is absurd. The split logic is important, not the number. As far as AM is concerned, there are still the same final number of maps, splitting is to help you understand your mappings and hopefully where the problem lies. – Lucian Bargaoanu Oct 05 '20 at 13:46
  • @LucianBargaoanu I appreciate the responses. We're reducing the load on AutoMapper and writing specific methods for the common maps between layers. – James Selleck Oct 07 '20 at 08:42
  • Once you know what the problem is, it should be easy to go back and achieve the same thing with AM. – Lucian Bargaoanu Oct 07 '20 at 09:20

0 Answers0