Wojciech Szabowicz
Wojciech Szabowicz

Reputation: 4198

Vs Code debugging Blazor WASM standalone

I am trying to debug blazor wasm application using Visual Studio Code, and tried this method from documentation Debug ASP.NET Core Blazor WebAssembly

So I checked got nuget DevServer Package and VS Code Extensions that are needed that is C# for Visual Studio Code Extension and Microsoft.AspNetCore.Razor.VSCode.BlazorWasmDebuggingExtension.

Also I have my launchSettings.json:

{
  "profiles": {
    "Blazor.Wasm": {
      "commandName": "Project",
      "launchBrowser": true,
      "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
      "applicationUrl": "https://localhost:5001;http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

and VsCode launch.json:

{
    "version": "0.2.0",
    "configurations": [     
        {
            "name": ".NET Core Debug Blazor Web Assembly in Chrome",
            "type": "blazorwasm",
            "request": "launch",
            "url": "https://localhost:5001",
            "webRoot": "${workspaceFolder}"
        }
    ]
}

And in result I have an error message like bellow.

Error

But I see webpage has been started, i can go to https://localhost:5001 and it works, but when i put a breakpoint it is marked as unload, like debugger is not loaded or working at all.

What can be the problem of this?

Upvotes: 2

Views: 718

Answers (1)

Jorge Pinetta
Jorge Pinetta

Reputation: 31

the fix has not been published yet.

https://github.com/dotnet/aspnetcore/issues/45257 https://github.com/dotnet/aspnetcore/issues/45257#issuecomment-1357128650


This problem does not happen in VS2022.


In VS Code the way to debug is with chrome devtools as follows:

Launch the Blazor site from console

dotnet run

"chrome-path\chrome.exe" --remote-debugging-port=9222 --user-data-dir="user-data-root-path\AppData\Local\Temp\blazor-chrome-debug" schema:// localhost:port/

And now in chrome: shift+alt+D.

Then debug blazor in chrome devtools at source tab and search your code in file://.

Then add a breakpoint and inspect in devtools of chrome.


Update on 2023-02-02

blazorwasm-companion.launchDebugProxy v1.1.3 has been released today (2023-02-02) and resolves the issue.

Upvotes: 2

Related Questions