Notification does not appear on screen

I was using the Radzen NotificationService to display warning popups to the user and calling NotificationService.Notify was working fine in my code behind. However, I also wanted to log these warnings to my logger and add some additional details so I created a service with NotificationService being injected into the constructor. When I call my service ShowErrorNotification method, I can set a breakpoint where Notify is called and my code breaks at that point but I never see the notification popup on screen. This is a Blazor server project.

Any suggestions on what I am doing wrong?

Andy

Hi @AndyFraser,

This is almost certainly a DI lifetime mismatch. NotificationService is registered as Scoped (one instance per Blazor circuit), and RadzenComponents in your layout subscribes to the Messages collection of that circuit-scoped instance.

If your custom service is registered as AddSingleton, it captures a NotificationService from the root scope — a different instance than the one your layout is listening to. Notify runs against the wrong collection, so the breakpoint hits but nothing renders.

Register your wrapper as Scoped to match:

builder.Services.AddScoped<IMyNotificationService, MyNotificationService>();

@korchev Many thanks, that solved my problem.

Best Regards

Andy