Hi all
I try to @inject DialogService into my Blazor app but the compiler tells me that namespace 'DialogService' could not be found
Am I missing something?
Thanks
Nicola
Hi all
I try to @inject DialogService into my Blazor app but the compiler tells me that namespace 'DialogService' could not be found
Am I missing something?
Thanks
Nicola
You are missing @using Radzen
Thank you for your answer, i have the following exception now : Unhandled exception rendering component: Cannot provide a value for property 'dialogService' on type 'crm.Client.Pages.FetchBP_radzen'. There is no registered service of type 'Radzen.DialogService
Maybe you can get the source code of our demos to check how to register properly various services.
Hi
The source codes are for server side Blazor
Anyway i found this interesting article from microsoft:
You have to register DialogService into Main function in Program.cs of Client project
Thanks
Nicola
Hi @Sammy,
In web assembly you need to register the services in Program.cs of your Client project:
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddScoped<DialogService>();
builder.Services.AddScoped<NotificationService>();
builder.Services.AddScoped<TooltipService>();
builder.Services.AddScoped<ContextMenuService>();
This has worked, thanks so much.
How do we prevent Radzen from overwriting the service addition once the app runs? I added the new service in the file, but after running it gets removed by code generation. I'm not sure what method to use in a file like Program.Custom.cs.
Are you using Radzen? It already registers all required services in the startup of the application (either Program.cs or Startup.cs). To stop code generation from overwriting code you can use the code generation ignore list. Our new product Radzen Blazor Studio does not remove custom code.