Skip to content

Stackoverflow on upgrade of AutoMapper.Extensions.Microsoft.DependencyInjection #153

Closed

Description

@penfold

TLDR See whole chain of comments. It looks to be caused by AutoMapper.Extensions.Microsoft.DependencyInjection.

I'm getting a SO in Visual Studio when my WebApp starts up. I have extensive usage of Automapper, but I get nothing other that a SO. The call stack is:

System.Private.CoreLib.dll!System.RuntimeTypeHandle.GetGenericTypeDefinition(System.RuntimeType type)	Unknown
System.Private.CoreLib.dll!System.RuntimeType.GetGenericTypeDefinition()	Unknown

AutoMapper.Collection.dll!AutoMapper.Collection.TypeHelper.GetElementTypes(System.Type enumerableType, System.Collections.IEnumerable enumerable, AutoMapper.Collection.ElemntTypeFlags flags) Unknown
AutoMapper.Collection.dll!AutoMapper.Collection.TypeHelper.GetElementType(System.Type enumerableType) Unknown
AutoMapper.Collection.dll!AutoMapper.Mappers.EquivalentExpressionAddRemoveCollectionMapper.MapExpression(AutoMapper.IConfigurationProvider configurationProvider, AutoMapper.ProfileMap profileMap, AutoMapper.IMemberMap memberMap, System.Linq.Expressions.Expression sourceExpression, System.Linq.Expressions.Expression destExpression, System.Linq.Expressions.Expression contextExpression) Unknown
AutoMapper.Collection.dll!AutoMapper.Mappers.EquivalentExpressionAddRemoveCollectionMapper.MapExpression(AutoMapper.IConfigurationProvider configurationProvider, AutoMapper.ProfileMap profileMap, AutoMapper.IMemberMap memberMap, System.Linq.Expressions.Expression sourceExpression, System.Linq.Expressions.Expression destExpression, System.Linq.Expressions.Expression contextExpression) Unknown
.
.
. AutoMapper.Collection.dll!AutoMapper.Mappers.EquivalentExpressionAddRemoveCollectionMapper.MapExpression(AutoMapper.IConfigurationProvider configurationProvider, AutoMapper.ProfileMap profileMap, AutoMapper.IMemberMap memberMap, System.Linq.Expressions.Expression sourceExpression, System.Linq.Expressions.Expression destExpression, System.Linq.Expressions.Expression contextExpression) Unknown

Then SO.

Are you able to give me an idea of how I could start to debug this? (There's not much to go on.)

Thanks,
Paul

Activity

  1. penfold commented on Nov 12, 2020

    @penfold
    Author

    When I comment out AM.Coll, the SO does not occur.

    services.AddAutoMapper(configurationExpression =>
    {
    //configurationExpression.AddCollectionMappers();
    },
    typeof(MapperFactoryExtensions).Assembly);

  2. penfold commented on Nov 12, 2020

    @penfold
    Author

    Upgrading from AM 9.0.0 to 10.1.1 and AM.Coll 6.0.0 to 7.0.0. (And .net core 3.1 to .net 5)

  3. penfold commented on Nov 13, 2020

    @penfold
    Author

    Is it possible have some exception handling in that stack to get feedback on which types are causing the issue?

  4. penfold commented on Nov 13, 2020

    @penfold
    Author

    I've grabbed all of the source code to help debug. It seems to be stumbling (in a recursive way) when calling EquivalentExpressionAddRemoveCollectionMapper.MapExpression(...) for

    .ForMember(d => d.Errors, o => o.MapFrom((s, d) => s.Errors?.Split(';')));

    This is string[] to IList<string> .

  5. penfold commented on Nov 14, 2020

    @penfold
    Author

    I've tested my .net core 3.1 branch with the latest versions of AM and AM.Coll. This looks to be working correctly.

    I then updated AutoMapper.Extensions.Microsoft.DependencyInjection and the SO is now seen.

  6. changed the title [-]Stackoverflow on upgrade to latest version[/-] [+]Stackoverflow on upgrade to .net 5[/+] on Nov 14, 2020
  7. changed the title [-]Stackoverflow on upgrade to .net 5[/-] [+]Stackoverflow on upgrade of AutoMapper.Extensions.Microsoft.DependencyInjection[/+] on Nov 14, 2020
  8. TylerCarlson1 commented on Nov 15, 2020

    @TylerCarlson1
    Member

    Seems very similar to #151. Preserve References is not getting used and goes into SO loop.

    You can try updating to 7.0.1-ci-00105 from nuget feed AM-prerelease and see if that fixes your problem

  9. gokhanabatay commented on Nov 18, 2020

    @gokhanabatay

    Same issue with .net 5.0 AutoMapper 10.1.1, AutoMapper.Collection 7.0.0, AutoMapper.Extensions.Microsoft.DependencyInjection 8.1.0

  10. esabah commented on Nov 18, 2020

    @esabah

    I am getting error with
    .net 5.0 , AutoMapper 10.1.1, AutoMapper.Collection 7.0.0, AutoMapper.Extensions.Microsoft.DependencyInjection 8.1.0.

    I tried AutoMapperCollection 7.0.1-ci-00105 and worked without errors.
    When do you plan to release this fix? Thanks.

  11. TylerCarlson1 commented on Nov 18, 2020

    @TylerCarlson1
    Member

    When I fix the deployment pipeline to nuget which has changed to GitHub Actions from AppVoyer

  12. TylerCarlson1 commented on Nov 23, 2020

    @TylerCarlson1
    Member

    Got it pushed fix is in 7.0.1

  13. rcdailey commented on Sep 24, 2023

    @rcdailey

    I'd just like to point out that I'm getting this exact same issue. I'm running AutoMapper v12.0.1 and AutoMapper.Collection v9.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions