Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there support for Razor Components (aka server side Blazor)? #676

dharmaturtle opened this Issue Mar 20, 2019 · 4 comments


None yet
2 participants
Copy link

commented Mar 20, 2019


Thanks for a great framework! I've used it in the past, and hope to get it working with my current Razor Components project.

Steps to recreate:

  1. Install the prerequisites.
  2. Run dotnet new razorcomponents -o MyRazorComponents
  3. Modify Startup.cs to match the documentation as much as possible. The before and after diff can be found here.
  4. Run dotnet watch run
  5. Observe the following exception despite .Verify() passing:

Unhandled exception rendering component: Cannot provide a value for property 'ForecastService' on type 'MyRazorComponents.Components.Pages.FetchData'. There is no registered service of type 'MyRazorComponents.Services.WeatherForecastService'.

I'm unfamiliar with crosswiring and ASP.NET; please let me know if I made any errors. Blazor initially did not support custom service providers, but that was fixed recently. AutoFac seems to work, so I feel like I'm missing something. I'm using SimpleInjector v4.4.3 (and Integration.AspNetCore.Mvc v4.4.3). Thanks again!


This comment has been minimized.

Copy link

commented Mar 20, 2019

I tried to get the full stack working with VS2019prev, .NET Core v3, templates, etc, but for some reason the razorcomponents is unknown and VS 2019 doesn't have any Target framework beyond .NET Standard 2.0.

Can you provide me with a .zip file of your solution?

And don't forget to post the full stack trace.


This comment has been minimized.

Copy link

commented Mar 20, 2019

You used to have to install the Blazor extension to get the dotnet templates working. Now, as far as I can tell, it's major benefit is giving you intellisense in .razor files.

When I run dotnet --version, I get 3.0.100-preview3-010431. Merely creating a .NET Core Console app gives me <TargetFramework>netcoreapp3.0</TargetFramework>; I had no option to change frameworks. (At least from a new start of VS19.)

I threw it on github here.

Stack trace:

Unhandled exception rendering component: Cannot provide a value for property 'ForecastService' on type 'MyRazorComponents.Components.Pages.FetchData'. There is no registered service of type 'MyRazorComponents.Services.WeatherForecastService'.
System.InvalidOperationException: Cannot provide a value for property 'ForecastService' on type 'MyRazorComponents.Components.Pages.FetchData'. There is no registered service of type 'MyRazorComponents.Services.WeatherForecastService'.
   at Microsoft.AspNetCore.Components.ComponentFactory.<>c__DisplayClass6_0.<CreateInitializer>b__2(IComponent instance)
   at Microsoft.AspNetCore.Components.ComponentFactory.PerformPropertyInjection(IComponent instance)
   at Microsoft.AspNetCore.Components.ComponentFactory.InstantiateComponent(Type componentType)
   at Microsoft.AspNetCore.Components.Rendering.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)
   at Microsoft.AspNetCore.Components.Rendering.Renderer.Re
Process is terminating due to StackOverflowException.
nderInExistingBatch(RenderQueueEntry renderQueueEntry)
   at Microsoft.AspNetCore.Components.Rendering.Renderer.ProcessRenderQueue()
   at Microsoft.AspNetCore.Components.Rendering.Renderer.AddToRenderQueue(Int32 componentId, RenderFragment renderFragment)
   at Microsoft.AspNetCore.Components.RenderHandle.Render(RenderFragment renderFragment)
   at Microsoft.AspNetCore.Components.ComponentBase.StateHasChanged()
   at Microsoft.AspNetCore.Components.ComponentBase.CallOnParametersSetAsync()
   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()

I had to navigate to https://localhost:5001/fetchdata directly from a new tab to see the error in the dotnet watch run


This comment has been minimized.

Copy link

commented Mar 20, 2019

The stack trace gives some clues of what it going on. From that, we can take a peek in the actual source code.

A painful observation is that the building of these Razor Components is tightly coupled to the built-in configuration system, and I see no easy way to redirect the resolution of those components to a non-conforming container, such as Simple Injector.

Hopefully, this code isn't released yet and the Microsoft team can still make some changes to the design.

Hopefully @davidfowl can chime in and correct me if I'm wrong.

David, am I correct by saying the necessary Seam is missing in this part of the ASP.NET Core code base or is there a different way for non-conformers to plugin at this point? If there's no way to integrate, can you make sure this is something that will be addressed?


This comment has been minimized.

Copy link

commented Mar 28, 2019

Let's see what happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.