C
C#13mo ago
Elban

.NET 8 Wasm/Server Browser Error

After Updating my old Wasm/Server Side hosting model to the new .NET 8 included one I get errors I can't debug: Browser Error: Uncaught (in promise) Error: Failed to start platform. Reason: TypeError: Cannot read properties of undefined (reading 'AspNetCore') at ei (blazor.web.js:1:163657) My Server Middlewares and maps:
//--------------------------------------------------------------------------------------
// Application Startup Configuration (Middleware, Routing, ...)
//--------------------------------------------------------------------------------------

WebApplication app = builder.Build();

if (!swaggerOnly)
{
UseEnviromentBasedMiddlewares(app);
}

app.UseHttpsRedirection()
.UseExceptionHandler()
.UseSwaggerMiddleware(useSwaggerUI: app.Environment.IsDevelopment())
.UseStaticFiles()
.UseSerilogRequestLogging()
.UseRouting()
.UseAntiforgery()
.UseMentionAuthentication()
.UseOutputCache()
.UseConnectionStringWaiter()
.UseRequestLocalization()
.UseUserFactory();

app.MapRazorComponents<Pages.Host>()
.AddInteractiveServerRenderMode()
.AddInteractiveWebAssemblyRenderMode()
.AddAdditionalAssemblies(typeof(Client.Program).Assembly)
.AllowAnonymous();

app.MapAuthenticationEndpoints()
.MapLoggingEndpoints()
.MapMentionUserEndpoint()
.MapLicenceEndpoints()
.MapModuleEndpoints();

app.Run();
//--------------------------------------------------------------------------------------
// Application Startup Configuration (Middleware, Routing, ...)
//--------------------------------------------------------------------------------------

WebApplication app = builder.Build();

if (!swaggerOnly)
{
UseEnviromentBasedMiddlewares(app);
}

app.UseHttpsRedirection()
.UseExceptionHandler()
.UseSwaggerMiddleware(useSwaggerUI: app.Environment.IsDevelopment())
.UseStaticFiles()
.UseSerilogRequestLogging()
.UseRouting()
.UseAntiforgery()
.UseMentionAuthentication()
.UseOutputCache()
.UseConnectionStringWaiter()
.UseRequestLocalization()
.UseUserFactory();

app.MapRazorComponents<Pages.Host>()
.AddInteractiveServerRenderMode()
.AddInteractiveWebAssemblyRenderMode()
.AddAdditionalAssemblies(typeof(Client.Program).Assembly)
.AllowAnonymous();

app.MapAuthenticationEndpoints()
.MapLoggingEndpoints()
.MapMentionUserEndpoint()
.MapLicenceEndpoints()
.MapModuleEndpoints();

app.Run();
my Client program.cs:
private static async Task Main(string[] args)
{
WebAssemblyHostBuilder builder = WebAssemblyHostBuilder.CreateDefault(args);

builder.Logging.Services.AddCriticalLoggingProvider(builder.HostEnvironment.BaseAddress);

AddBlazorFrameworkSpecificServices(builder.Services);
AddHttpClientServices(builder.Services, builder.HostEnvironment.BaseAddress, (sp, handlers) =>
{
handlers.Add(sp.GetRequiredService<HostNameMessageHandler>());
});

AddServices(builder.Services);

WebAssemblyHost app = builder.Build();

await SetBlazorCultureAsync(app.Services);

await app.RunAsync();
}
private static async Task Main(string[] args)
{
WebAssemblyHostBuilder builder = WebAssemblyHostBuilder.CreateDefault(args);

builder.Logging.Services.AddCriticalLoggingProvider(builder.HostEnvironment.BaseAddress);

AddBlazorFrameworkSpecificServices(builder.Services);
AddHttpClientServices(builder.Services, builder.HostEnvironment.BaseAddress, (sp, handlers) =>
{
handlers.Add(sp.GetRequiredService<HostNameMessageHandler>());
});

AddServices(builder.Services);

WebAssemblyHost app = builder.Build();

await SetBlazorCultureAsync(app.Services);

await app.RunAsync();
}
1 Reply
Elban
ElbanOP13mo ago
Fixed: resolved the issue by removing the bin/obj folder from all my projects
Want results from more Discord servers?
Add your server