© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•15mo ago•
21 replies
Grault

Blazor WASM: Injecting a service

I'm trying to inject a service to extract details (dimensions, so far) of the browser. The code for the service is from https://blazor.tips/blazor-how-to-ready-window-dimensions/ .

The service is registered in the Client project's Program.cs:
builder.Services.AddScoped<BrowserService>();
builder.Services.AddScoped<BrowserService>();

Obviously the service needs to be entirely on the client, so the component which consumes it has:
@rendermode InteractiveWebAssembly
@inject BrowserService Browser
@rendermode InteractiveWebAssembly
@inject BrowserService Browser

When I run the project and open the page which contains the component, I receive:
>InvalidOperationException: Cannot provide a value for property 'Browser' on type 'Quilt.Client.Components.Sheet'. There is no registered service of type 'Quilt.Client.Utilities.BrowserService'.

Is some of the component running on the server? Why?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Blazor WASM Headers
C#CC# / help
4mo ago
Blazor wasm help
C#CC# / help
6mo ago
Blazor WASM Authentication
C#CC# / help
2y ago
❔ Blazor WASM & NetlifyCMS
C#CC# / help
3y ago