© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
2 replies
BigggMoustache

❔ Registered Services ArMissing

This is in a Hosted Blazor WASM Client project in case that matters. The Index page injecting dependency for UserAuthenticationStateProvider and UserService, which give missing type or namespace error.
) There's no typos lol
@page "/"
@inject IJSRuntime JSRuntime
@inject NavigationManager NavigationManager
@inject UserAuthenticationStateProvider UserAuthenticationStateProvider
@inject UserService UserService

<PageTitle>Index</PageTitle>

<div>Full name: @UserAuthenticationStateProvider.CurrentUser.FullName</div>
<div>Username: @UserAuthenticationStateProvider.CurrentUser.Username</div>
<div>Token: @UserService._authenticationDataMemoryStorage.Token</div>
@page "/"
@inject IJSRuntime JSRuntime
@inject NavigationManager NavigationManager
@inject UserAuthenticationStateProvider UserAuthenticationStateProvider
@inject UserService UserService

<PageTitle>Index</PageTitle>

<div>Full name: @UserAuthenticationStateProvider.CurrentUser.FullName</div>
<div>Username: @UserAuthenticationStateProvider.CurrentUser.Username</div>
<div>Token: @UserService._authenticationDataMemoryStorage.Token</div>


here's the program.cs builder stuff

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddScoped<AuthenticationDataMemoryStorage>();
builder.Services.AddScoped<UserService>();
builder.Services.AddScoped<UserAuthenticationStateProvider>();
builder.Services.AddScoped<AuthenticationStateProvider>(sp => sp.GetRequiredService<UserAuthenticationStateProvider>());
builder.Services.AddAuthorizationCore();

await builder.Build().RunAsync();
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddScoped<AuthenticationDataMemoryStorage>();
builder.Services.AddScoped<UserService>();
builder.Services.AddScoped<UserAuthenticationStateProvider>();
builder.Services.AddScoped<AuthenticationStateProvider>(sp => sp.GetRequiredService<UserAuthenticationStateProvider>());
builder.Services.AddAuthorizationCore();

await builder.Build().RunAsync();
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

AboutView not registered?
C#CC# / help
11mo ago
❔ Services communication in Windows Services
C#CC# / help
3y ago
✅ unregistered services
C#CC# / help
2y ago
Blazor Services
C#CC# / help
3y ago