How to solve StackOverflowException after upgrading from AutoMapper 8 to 11.0.0

Viewed 222

https://github.com/beolafsen/TestAutomapperAndStripe

I get this errors after upgrade AutoMapper.Extensions.Microsoft.DependencyInjection from 8.1.1 to 11.0.0.

The messages I get are: "An unhandled exception of type 'System.StackOverflowException' occurred in System.Private.CoreLib.dll." (No other hint where or what causes the error).

and

enter image description here

I use .Net 6.0/BlazorServerSide

I have found that the following Automapper definitions are causing the error.

using Stripe;
    CreateMap<VMStripeInvoiceItem, Stripe.InvoiceItem>();
    CreateMap<Stripe.InvoiceItem, VMStripeInvoiceItem>()
                    .ForMember(pts => pts.LineAmount, opt => opt.MapFrom(ps => ps.Quantity * (ps.UnitAmountDecimal ?? (decimal)0) * (decimal)0.01))
                    .ForMember(pts => pts.UnitAmountDecimal, opt => opt.MapFrom(ps => (ps.UnitAmountDecimal ?? (decimal)0) * (decimal)0.01));

public class VMStripeInvoiceItem : InvoiceItem
    {
        public decimal LineAmount { get; set; }
    }

How can this be solved?

Thanks for helping!

Best regards BEO

0 Answers
Related