Blazor Error - There is no Registered Service of Type

Experimenting with Blazor, I ran into this error showing up in the console: "There is no registered service of type..." Fortunately there is a simple fix. In my case, I added a class & injected into a Razor view. What I forgot to do, was add it as a service in Program.cs. In my case, my well named class was named Stuff because I was truly experimenting & naming things is hard.

By injecting a service to my Program.cs, the error went away & my program executed without any issues.

    public class Program
        static void Main(string[] args)
            var serviceProvider = new BrowserServiceProvider(services =>

            new BrowserRenderer(serviceProvider).AddComponent<App>("app");

Matt Ferderer

Software engineer who spends his time learning about building teams, project management, software architecture, C#, .NET Core, Blazor, JavaScript, TypeScript, Azure, user experience, web security, and performance.