System.InvalidOperationException: Cannot provide a value for property 'DialogService' on type 'LumosR.Pages.AddAssignment'. There is no registered service of type 'Radzen.DialogService'.
at Microsoft.AspNetCore.Components.ComponentFactory.<>c__DisplayClass9_0.<CreatePropertyInjector>g__Initialize|1(IServiceProvider serviceProvider, IComponent component)
at Microsoft.AspNetCore.Components.ComponentFactory.InstantiateComponent(IServiceProvider serviceProvider, Type componentType, IComponentRenderMode callerSpecifiedRenderMode, Nullable`1 parentComponentId)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.InstantiateChildComponentOnFrame(RenderTreeFrame[] frames, Int32 frameIndex, Int32 parentComponentId)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewComponentFrame(DiffContext& diffContext, Int32 frameIndex)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewSubtree(DiffContext& diffContext, Int32 frameIndex)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& diffContext, Int32 newFrameIndex)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer renderer, RenderBatchBuilder batchBuilder, Int32 componentId, ArrayRange`1 oldTree, ArrayRange`1 newTree)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()
--- End of stack trace from previous location ---
at Radzen.Server.RemoteRenderer.HandleException(Exception exception)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()
at Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToRenderQueue(Int32 componentId, RenderFragment renderFragment)
at Radzen.Server.Router.Render(Type layout, Type component, Boolean renderLayout)
at Radzen.Server.Router.OnRouteChanged(Object sender, RouteChangedEventArgs e)
at Radzen.Server.RouterService.Route(Type component, Type defaultLayout, Boolean renderLayout)
at Radzen.Server.CircuitHost.AddComponent(Type layout, Type page, Boolean renderLayout)
at Radzen.Server.ProjectServer.Render(String fileName, String source, Boolean renderLayout)
at Radzen.Server.ProgramController.Render(RenderRequest request)
I'm getting the same peculiar error when using the Radzen Design View through Radzen Blazor Studio for Visual Studio or through Radzen Blazor Studio IDE. I moved all the builder services to a ServiceCollectionBuilder extension class and the subsequent App Middleware configurations to an ApplicationBuilderExtension class. Even though the Build appears to be complete usually, I cannot use the Design-Time Render Layout in either Visual Studio 2022 IDE or Radzen Blazor Studio IDE. Do you have any ideas as to what could be the problem?
I added the ProductBarcodeValidatorProject to the project, and I did what you recommended with no change. Also, the builder.Services.AddRadzenComponents(); statement is already in the ServiceCollectionBuilderExtensions.cs. Should I remove it from the extension and place it directly in the Program.cs, or should I add each component individually as a scoped service?
I think that you misunderstand. I added the #if RADZEN
builder.Services.AddRadzenComponents(); #endif
as you suggested, and there was no change. It still generated the same error.
Page Cannor be Rendered:
System.InvalidOperationException: Cannot provide a value for property 'DialogService' on type 'VisionSuiteShipManagerServer.Components.Layout.MainLayout'. There is no registered service of type 'Radzen.DialogService'.
at Microsoft.AspNetCore.Components.ComponentFactory.<>c__DisplayClass9_0.g__Initialize|1(IServiceProvider serviceProvider, IComponent component)
at Microsoft.AspNetCore.Components.ComponentFactory.InstantiateComponent(IServiceProvider serviceProvider, Type componentType, IComponentRenderMode callerSpecifiedRenderMode, Nullable1 parentComponentId) at Microsoft.AspNetCore.Components.RenderTree.Renderer.InstantiateChildComponentOnFrame(RenderTreeFrame[] frames, Int32 frameIndex, Int32 parentComponentId) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewComponentFrame(DiffContext& diffContext, Int32 frameIndex) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewSubtree(DiffContext& diffContext, Int32 frameIndex) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& diffContext, Int32 newFrameIndex) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl) at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer renderer, RenderBatchBuilder batchBuilder, Int32 componentId, ArrayRange1 oldTree, ArrayRange`1 newTree)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()
--- End of stack trace from previous location ---
at Radzen.Server.RemoteRenderer.HandleException(Exception exception)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()
at Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToRenderQueue(Int32 componentId, RenderFragment renderFragment)
at Radzen.Server.Router.Render(Type layout, Type component, Boolean renderLayout)
at Radzen.Server.Router.OnRouteChanged(Object sender, RouteChangedEventArgs e)
at Radzen.Server.RouterService.Route(Type component, Type defaultLayout, Boolean renderLayout)
at Radzen.Server.CircuitHost.AddComponent(Type layout, Type page, Boolean renderLayout)
at Radzen.Server.ProjectServer.Render(String fileName, String source, Boolean renderLayout)
at Radzen.Server.ProgramController.Render(RenderRequest request)
I placed it after the AddApplication Services call in the Program.cs file.
Log.Information("Starting web application");
var builder = WebApplication.CreateBuilder(args);
// Add services to the container
Log.Information("Adding Application Services to the container");
await builder.Services.AddApplicationServices(builder.Configuration, builder.Environment).ConfigureAwait(false);
I can't open the updated solution. It refers to a project I don't have:
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProductBarcodeValidator", "..\..\..\Libraries\Generic\ProductBarcodeValidator\ProductBarcodeValidator\ProductBarcodeValidator.csproj", "{4EBD590A-1B4F-48F6-8ED2-01B5E544CE54}"
EndProject
G
I also checked the updated Program.cs - it still doesn't include the requested change:
using System.IdentityModel.Tokens.Jwt;
using Brickmakers.AspSecurityHeaders;
using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.OData;
using Microsoft.EntityFrameworkCore;
using Microsoft.OData.ModelBuilder;
using Radzen;
using Serilog;
using VisionSuiteShipManagerServer.Components;
using VisionSuiteShipManagerServer.Data;
using VisionSuiteShipManagerServer.Exceptions;
using VisionSuiteShipManagerServer.Extensions;
using VisionSuiteShipManagerServer.Models;
using VisionSuiteShipManagerServer.Services;
// Setup Serilog for logging
var configuration = new ConfigurationBuilder().BuildConfiguration();
Log.Logger = await configuration.CreateBootstrapLoggerAsync().ConfigureAwait(false);
try
{
Log.Information("Starting web application");
var builder = WebApplication.CreateBuilder(args);
// Add services to the container
Log.Information("Adding Application Services to the container");
await builder.Services.AddApplicationServices(builder.Configuration, builder.Environment).ConfigureAwait(false);
Log.Information("Building the API");
var app = builder.Build();
// Configure the HTTP request pipeline
Log.Information("Configuring the HTTP request pipeline");
await app.ConfigureMiddlewareAsync().ConfigureAwait(false);
// Ensures that the Database Associated with ApplicationIdentityDbContext is Created Asynchronously,
// if it does not already exist.
Log.Information(" => Processing Application Database Context Create (if not exist) Asynchronously");
await app.Services.CreateScope()
.ServiceProvider.GetRequiredService<ApplicationIdentityDbContext>()
.Database.EnsureCreatedAsync()
.ConfigureAwait(false);
// Ensures that the Database Schema Associated with ApplicationIdentityDbContext is Migrated Asynchronously,
// if it does not already exist.
Log.Information(" => Processing Application Database Schema Migrate (if not exist) Asynchronously");
await app.Services.CreateScope()
.ServiceProvider.GetRequiredService<ApplicationIdentityDbContext>()
.Database.MigrateAsync()
.ConfigureAwait(false);
Log.Information("Running the Application");
GlobalDataService.ApplicationStartDate = DateTime.Now;
await app.RunAsync().ConfigureAwait(false);
//app.Run();
Log.Information("Stopped cleanly");
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, "An unhandled exception occurred during bootstrapping");
return 1;
}
finally
{
Log.CloseAndFlush();
}
I am afraid I can't do much to help in this situation.
using System.IdentityModel.Tokens.Jwt;
using Brickmakers.AspSecurityHeaders;
using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.OData;
using Microsoft.EntityFrameworkCore;
using Microsoft.OData.ModelBuilder;
using Radzen;
using Serilog;
using VisionSuiteShipManagerServer.Components;
using VisionSuiteShipManagerServer.Data;
using VisionSuiteShipManagerServer.Exceptions;
using VisionSuiteShipManagerServer.Extensions;
using VisionSuiteShipManagerServer.Models;
using VisionSuiteShipManagerServer.Services;
// Setup Serilog for logging
var configuration = new ConfigurationBuilder().BuildConfiguration();
Log.Logger = await configuration.CreateBootstrapLoggerAsync().ConfigureAwait(false);
try
{
Log.Information("Starting web application");
var builder = WebApplication.CreateBuilder(args);
// Add services to the container
Log.Information("Adding Application Services to the container");
await builder.Services.AddApplicationServices(builder.Configuration, builder.Environment).ConfigureAwait(false);
//*****************************************************************************************************************
// WPE (20250110) - Add the following to the Add the Radzen Components in the Program.cs file Just in Case
// It's Missed I Guess
//*****************************************************************************************************************
Log.Information("Building the API");
var app = builder.Build();
// Configure the HTTP request pipeline
Log.Information("Configuring the HTTP request pipeline");
await app.ConfigureMiddlewareAsync().ConfigureAwait(false);
// Ensures that the Database Associated with ApplicationIdentityDbContext is Created Asynchronously,
// if it does not already exist.
Log.Information(" => Processing Application Database Context Create (if not exist) Asynchronously");
await app.Services.CreateScope()
.ServiceProvider.GetRequiredService<ApplicationIdentityDbContext>()
.Database.EnsureCreatedAsync()
.ConfigureAwait(false);
// Ensures that the Database Schema Associated with ApplicationIdentityDbContext is Migrated Asynchronously,
// if it does not already exist.
Log.Information(" => Processing Application Database Schema Migrate (if not exist) Asynchronously");
await app.Services.CreateScope()
.ServiceProvider.GetRequiredService<ApplicationIdentityDbContext>()
.Database.MigrateAsync()
.ConfigureAwait(false);
Log.Information("Running the Application");
GlobalDataService.ApplicationStartDate = DateTime.Now;
await app.RunAsync().ConfigureAwait(false);
//app.Run();
Log.Information("Stopped cleanly");
return 0;
I added code to the Program.cs file that verifys whether ALL Registered Services when the Web Application Loads and ALL Radzen Components are loaded correctly. Additionally, I am attaching the Radzen Analysis Log and a Screenshot of the transient error message that I saw during the Index.razor / Index.razor.cs Design-Time Build before the build failure.
The latest zip file again uses a project which is not included. I cannot test it.
The problem is the same which I have reported earlier.
By the way the code I have requested you to add is commented in Program.cs. It won't run during design-time builds.
try
{
Log.Information("Starting web application");
var builder = WebApplication.CreateBuilder(args);
// Add services to the container
Log.Information("Adding Application Services to the container");
await builder.Services.AddApplicationServices(builder.Configuration, builder.Environment).ConfigureAwait(false);
//*****************************************************************************************************************
// WPE (20250110) - Add the following to the Add the Radzen Components in the Program.cs file Just in Case
// It's Missed I Guess
//*****************************************************************************************************************
//#if RADZEN
// Log.Information(" => Re-Adding Radzen Components");
// builder.Services.AddRadzenComponents();
// builder.Services.AddRadzenCookieThemeService(options =>
// {
// options.Name = "VisionSuiteShipManagerServerTheme";
// options.Duration = TimeSpan.FromDays(365);
// });
//#endif
Finally I am positive your project used to work quite well in design time when I tested an earlier version of it (one that didn't start the browser because you have stopped logging to the terminal). I suggest using source control to find which change made this design-time error to start appearing.
I guess I will have to build a special application for you without the ProductBarcodeValidator project because it is a referenced project that I can't set up for you. I also noticed a bug in the Authorization Controller that has to do with multiple users that have TwoFactorEnabled set as true and false per user. In other words, you cannot have 2 or more users having different boolean settings for the TwoFactorEnabled column. It's either all or nothing as it conflicts with the TwoFactorRequired state. So it will be a day.