Hello lovely people,
thank you for helping out others and your effort ![]()
I tried to make Radzen Blazor Studio work with Razor Class Libraries (RCLs), but the Radzen Studio Designer breaks when I do this.
The starting point was a fresh project created via Radzen Studio.
From there I added a second csproj with <Project Sdk="Microsoft.NET.Sdk.Razor">
After that I
- moved all components (Index.razor, MainLayout.razor, Routes.razor) to the new RCL project
- updated namespaces
- moved wwwroot to the RCL project
- updated relative paths for css/js files
- added missing Nugets (since the SDK is different)
- Made sure "RadzenComponents" and "@rendermode InteractiveServer" was set in MainLayout.razor
The app works fine when starting it and viewing it in a normal browser.
However, the main selling point for me is the Visual Designer.
And the Designer is complaining "The page cannot render" when viewing MainLayout.razor or Index.razor
The error presented inside Radzen Studio is
Summary
Cannot provide a value for property 'DialogService' on type 'Frontend.Shared.Components.Layout.MainLayout'. 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)
When using the Radzen.Server.dll analyzer I get this error
Summary
Analyzing Frontend.Browser.sln ...
Analyzing D:\Code\radzen-testing\src\Frontend.Shared\Frontend.Shared.csproj ...
Rendering Components\Layout\MainLayout.razor ... FAIL.
System.ArgumentNullException: Value cannot be null. (Parameter 'provider')
at System.ThrowHelper.Throw(String paramName)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetComponentActivatorOrDefault(IServiceProvider serviceProvider)
at Microsoft.AspNetCore.Components.RenderTree.Renderer..ctor(IServiceProvider serviceProvider, ILoggerFactory loggerFactory)
at Radzen.Server.HtmlRenderer..ctor(IServiceProvider serviceProvider, ILoggerFactory loggerFactory, Func2 htmlEncoder) at Radzen.Server.ProjectServer.Crawl(String fileName, String source) at Radzen.Server.ProjectAnalyzer.AnalyzeFile(ProjectContext projectContext, SolutionFacade solutionFacade, String razorFile, Boolean parallel, Boolean all, CancellationToken token) Rendering Components\Pages\Index.razor ... FAIL. System.ArgumentNullException: Value cannot be null. (Parameter 'provider') at System.ThrowHelper.Throw(String paramName) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetComponentActivatorOrDefault(IServiceProvider serviceProvider) at Microsoft.AspNetCore.Components.RenderTree.Renderer..ctor(IServiceProvider serviceProvider, ILoggerFactory loggerFactory) at Radzen.Server.HtmlRenderer..ctor(IServiceProvider serviceProvider, ILoggerFactory loggerFactory, Func2 htmlEncoder)
at Radzen.Server.ProjectServer.Crawl(String fileName, String source)
at Radzen.Server.ProjectAnalyzer.AnalyzeFile(ProjectContext projectContext, SolutionFacade solutionFacade, String razorFile, Boolean parallel, Boolean all, CancellationToken token)
Done.
Analyzing D:\Code\radzen-testing\src\Frontend.Browser\Frontend.Browser.csproj ...
Done.
Finished with errors.
I tried to inject the necessary services like DialogService via program.cs, didn't help
Here is my current code: GitHub - nixdagbibts/radzen-testing
