Page failed to load

Hello Radzen team,
i try to start with blazor studio but i cant open any page. It seems that it has something to do with my service "Trentservice" which i use in every page.

System.InvalidOperationException: Cannot provide a value for property 'TrentService' on type 'Trent.Shared.MainLayout'. There is no registered service of type 'Trent.Services.TrentService'.
   at Microsoft.AspNetCore.Components.ComponentFactory.<>c__DisplayClass7_0.<CreateInitializer>g__Initialize|1(IServiceProvider serviceProvider, IComponent component)
   at Microsoft.AspNetCore.Components.ComponentFactory.PerformPropertyInjection(IServiceProvider serviceProvider, IComponent instance)
   at Microsoft.AspNetCore.Components.ComponentFactory.InstantiateComponent(IServiceProvider serviceProvider, Type componentType)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.InstantiateChildComponentOnFrame(RenderTreeFrame& frame, 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.OnRouteChanged(Object sender, RouteChangedEventArgs e) 
   at Radzen.Server.RouterService.Route(Type component, Type defaultLayout) 
   at Radzen.Server.CircuitHost.AddComponent(Type layout, Type page) 
   at Radzen.Server.ProjectServer.Render(String fileName, String source) 
   at Radzen.Server.ProgramController.Render(RenderRequest request)

What can i do?

Kind Regards
Thomas

Send us your app to info@radzen.com and we will see why this service isn't registered.

sent to info@radzen.com

We haven't received anything yet. Your attachment is probably too big. Either reduce its size to below 10MB (by deleting any .git, bin and obj directories) or use some cloud storage service to share the file and email us the link.

Hi @korchev,
i tried to sent "trent.zip" to info@radzen.com but i receive the following error:
info@radzen.com:

SMTP error from remote server for TEXT command, host: mx.zoho.com (136.143.191.44) reason: 552 5.7.1 The attachments you have added violate the Secure Attachment Pol icy. <a href=https://www.zoho.com/mail/help/secure-attachment-policy.h

tml target=_blank>Learn more

Size is around 7 MB

Hello radzen team,
no time to test it earlier... :confounded:

RBS 1.0.5 did it!
Thank you very much!

Thomas

I have a similar issue. All pages will not load after trying to use a service defined in Program.cs.

The Error is:
Cannot provide a value for property '_dbContext' on type 'WTVAdmin.Pages.ExecuteSQL'. There is no registered service of type 'WTVAdmin.Data.WhereToVote2023Context'.

When I register the service like this:
builder.Services.AddDbContext<WTVAdmin.Data.WhereToVote2023Context>(options =>
{
options.UseSqlServer(builder.Configuration.GetConnectionString("WhereToVote2023Connection"));
});
there is no problem.

When I register it like this:
builder.Services.AddDbContext<WTVAdmin.Data.WhereToVote2023Context>((serviceProvider, options) =>
{
var connectionStringService = serviceProvider.GetRequiredService();
var config = serviceProvider.GetRequiredService();
var connectionString = string.IsNullOrEmpty(connectionStringService.CurrentConnectionString)
? config.GetConnectionString("WhereToVote2023Connection")
: connectionStringService.CurrentConnectionString;
options.UseSqlServer(connectionString);
});
I get the error above.

The weird thing is that either way, it compiles and runs just fine in Visual Studio 2022.

I'm using version 1.13.1

Hi @Len_Hannam,

You can try using preprocessor:

builder.Services.AddDbContext<WTVAdmin.Data.WhereToVote2023Context>(options =>
{
#if RADZEN
options.UseSqlServer(builder.Configuration.GetConnectionString("WhereToVote2023Connection"));
#else
var connectionStringService = serviceProvider.GetRequiredService();
var config = serviceProvider.GetRequiredService();
var connectionString = string.IsNullOrEmpty(connectionStringService.CurrentConnectionString)
? config.GetConnectionString("WhereToVote2023Connection")
: connectionStringService.CurrentConnectionString;
options.UseSqlServer(connectionString);
#endif
});