❔ 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();
2 Replies
BigggMoustache
BigggMoustache11mo ago
Here's the top of one of the services that don't show up
namespace DiscordClone.Client.Services
{
public class UserAuthenticationStateProvider : AuthenticationStateProvider, IDisposable
{
namespace DiscordClone.Client.Services
{
public class UserAuthenticationStateProvider : AuthenticationStateProvider, IDisposable
{
Accord
Accord11mo ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.