Search code examples
blazorblazor-server-side

More failed to launch debug adapter problems in a Blazor app


I am learning how to use Blazor by building an app to display data from a database I have at home. I'm using .NET 8. I have gotten an error that says:

Failed to launch debug adapter. Additional information may be available in the output window.

Unable to launch browser: "Could not open wss://localhost:7245/_framework/debug/ws-proxy?browser= wsAFF127.0.0.1A54997FdevtoolsFbrowserFd0b945cf-e9ea-4fe 6-ac63-0a3cfcc6e751"

I've looked up the error about failing to launch debug adapter here on SO, which led me to The Visual Studio 2022 Error "Failed to launch debug adapter. Additional information may be available in the output window." However, the best accepted answer to that question was to disable script debugging. I've already done that, but I still get that error.

Here is a code snippet from my Program.cs file from my Blazor Server App project:

            app.UseHttpsRedirection();

            app.UseStaticFiles();
            app.UseRouting();
            app.UseAntiforgery();

            app.MapRazorComponents<App>()
                .AddInteractiveServerRenderMode()
                .AddAdditionalAssemblies(typeof(Client._Imports).Assembly);

            app.Run();

It complains on the app.Run() call. What am I doing wrong?


Solution

  • After testing, I reproduced your problem:

    enter image description here

    Solution:

    You need to add and configure the interactive WebAssembly component service and the corresponding interactive WebAssembly rendering mode, and enable the WebAssembly debugging function to allow developers to debug WebAssembly code in the browser. Here is my serve side program.cs example for your reference:

    var builder = WebApplication.CreateBuilder(args);
    
    // Add services to the container.
    builder.Services.AddRazorComponents()
        .AddInteractiveServerComponents()
        .AddInteractiveWebAssemblyComponents();
    
    var app = builder.Build();
    
    // Configure the HTTP request pipeline.
    if (app.Environment.IsDevelopment())
    {
        app.UseWebAssemblyDebugging();
    }
    else
    {
        app.UseExceptionHandler("/Error", createScopeForErrors: true);
        // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
        app.UseHsts();
    }
    
    app.UseHttpsRedirection();
    
    app.UseStaticFiles();
    app.UseAntiforgery();
    
    app.MapRazorComponents<App>()
        .AddInteractiveServerRenderMode()
        .AddInteractiveWebAssemblyRenderMode()
        .AddAdditionalAssemblies(typeof(BlazorApp30.Client._Imports).Assembly);
    
    app.Run();
    

    When I start it, it works fine:

    enter image description here