Birthday Reminders - Postscript - Don't Repeat Yourself - Dependency Injection

Поделиться
HTML-код
  • Опубликовано: 7 окт 2024
  • After completing the Blazor Birthday Reminders project I was frustrated that I had copied and pasted code between files but couldn't work out how to 'extract' the copied code into a separate file or method. Dependency injection is the answer and this is how I implemented it.

Комментарии • 4

  • @MichaelTroulis
    @MichaelTroulis 2 года назад

    Excellent video. I didn't know you could do that! Very helpful!

  • @mariewebb2017
    @mariewebb2017 2 года назад

    Thank you for the video.
    I fixed the error. The error said: InvalidOperationException: Cannot consume scoped service 'BlazorBirthdayReminders.Data.IPersonService' from singleton 'BlazorBirthdayReminders.Data.IReminderService'. When I changed IRemiderService to Scoped, I got this error: Cannot resolve scoped service 'BlazorBirthdayReminders.Data.IReminderService' from root provider. Source=Microsoft.Extensions.DependencyInjection.
    I fixed the error by making these services all Transient. 🙂

    • @christopherbell7186
      @christopherbell7186  2 года назад

      Thanks for letting me know. Hopefully it will help others that have the same problem.