Scrutor icon indicating copy to clipboard operation
Scrutor copied to clipboard

Upgrade from 4.2.2 to 5.0.1

Open giakara opened this issue 1 year ago • 2 comments

services.AddScoped<PaymentInitiationService>() .AddScoped<IEntityService<PaymentInitiation>>(x => x.GetRequiredService<PaymentInitiationService>()) .Decorate<IEntityService<PaymentInitiation>, PaymentInitiationServiceWithCache>() .AddScoped<IPaymentInitiationService>(x => x.GetRequiredService<PaymentInitiationService>()) .Decorate<IPaymentInitiationService, PaymentInitiationServiceWithCache>() .AddScoped<IPaymentInitiationAuditService>(x => x.GetRequiredService<PaymentInitiationService>()); i Upgrade to 5.0.1 and now i get System.InvalidOperationException: 'A suitable constructor for type 'TenantConsentsServiceWithCache' could not be located. Ensure the type is concrete and all parameters of a public constructor are either registered as services or passed as arguments. Also ensure no extraneous arguments are provided.' image

giakara avatar Oct 18 '24 12:10 giakara

It's really hard to tell what's wrong here, especially since the code posted doesn't even compile. Do you have any more details on the registered services? Preferably a runnable repro?

khellang avatar Oct 19 '24 13:10 khellang

image this is the registraticon the problem is when i register IEntityService the exception i get is A suitable constructor for type 'Plutus.QuickPay.Application.Nbg.TenantConsentsServiceWithCache' could not be located. Ensure the type is concrete and all parameters of a public constructor are either registered as services or passed as arguments. Also ensure no extraneous arguments are provided. I ll try to give you an executable to reproduce it

giakara avatar Oct 21 '24 10:10 giakara

ProblemWithscruptor.zip i give you this sample project that it works with 4.2.2 and not in 5.0.1

giakara avatar Oct 22 '24 12:10 giakara

I am also running into this issue as well with 5.01 ... dozens of my registrations using Decorate (or TryDecorate) throw this error now. 😭 Reverting back to 4.2.2 in the meantime.

Mike-E-angelo avatar Oct 23 '24 18:10 Mike-E-angelo

I had the same problem. I used dummy handler to show the problem

        services.Decorate(typeof(INotificationHandler<>), typeof(DummyHandlerDecorator<>));

.
.
.

public sealed class DummyHandlerDecorator<TNotification> : INotificationHandler<TNotification>
        where TNotification : INotification
{
    public DummyHandlerDecorator()
    {
        
    }

    public async Task Handle(TNotification notfication, CancellationToken cancellationToken)
    {
        await Task.Delay(1000);
    }
}

I got an error stating that no suitable constructor was found, even when I used an empty one.

Mb this will help you to find the real problem.

dr-marek-jaskula avatar Nov 18 '24 13:11 dr-marek-jaskula

I have the same issue ;/

kwrobel-gor avatar Nov 20 '24 14:11 kwrobel-gor

Closed by #239

khellang avatar Dec 23 '24 08:12 khellang

Woohoo thank you very much for your efforts and diligence out there @khellang. It is appreciated. 🙏 Happy Holidays. 🎅⛄🦌

Mike-E-angelo avatar Dec 23 '24 08:12 Mike-E-angelo

Thanks for hanging in there, @Mike-E-angelo 😅🙏🏻 Happy holidays to you too! 🎅🏻

khellang avatar Dec 23 '24 08:12 khellang