6
votes

Breakpoints won't hit in ASP.NET Core 3.1, Blazor Webassembly project.

I have a solution with a single Blazor Webassembly project which I run locally.

When placing a breakpoint in a .cs file it says:

"The breakpoint will not currently be hit. A copy of Startup.cs was found in blazor-devserver.dll, but the current source code is different from the version built into blazor-devserver.dll.

To allow this breakpoint to be hit, click the 'Settings...' button that appears, then click 'Location', 'Allow the source code to be different from the original.' ..."

This seems strange to me because I don't deploy, I just hit F5 in Visual Studio so I don't see how the code can be different.

Wen the breakpoint is placed in a .razor file it says:

"The breakpoint will not currently be hit. No symbols have been loaded for this document"

In the modules window, symbols have been loaded for all entries.

It worked fine until recently. Only thing I did was installing Microsoft Code Anlysis 2019 (removed it again).

5
Did you try to delete obj and bin folder and rebuild ?agua from mars
@aguafrommars yes I did that, to no availDabriel

5 Answers

5
votes

Blazor Webassembly is still in preview stage hence you cannot debug the cs file directly. Debugging is supported via Chrome only. The details are documented here.

4
votes

I know this does not answer directly this question but this was only question that pop up on google. I couldn't get symbols loaded for blazor client (asp.net core hosted) when debugging. It turned out that I was missing one line in launchSettings.json in asp.net core server app.

"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"

Hope this will help someone.

3
votes

You can now Debug the Blazor WebAssembly using the Preview Version of Visual Studio 2019. You can check the details here

0
votes

Also using "inspectUri" in all profiles breakpoint still not to be hit for Razor components. I used as workaround to set "sslPort": 0 in launchsettings but now I can't use it otherwise I can't login in my Blazor Webassembly project. I'm working on a hosted Blazor WebAssembly App, configured for HTTPS, with authentication.

0
votes

I found that setting Windows to use Edge as a default browser and configuring the project to launch the browser, allows Visual Studio to configure and connect to the Edge browsing session.

  • Manually starting Edge did not work.
  • Starting Edge and hitting Shift+Alt+D did not work.
  • Starting Edge with the command line "msedge --remote-debugging-port=9222 --user-data-dir="C:\Users\MyUserProfile\AppData\Local\Temp\blazor-edge-debug" --no-first-run https://localhost:12345/" did not work.
  • Configuring firewall to accept incoming connections on TCP port 9222 did not work.

An alternative to setting a different default browser can be found at this article. This works just as well as setting Edge as the default browser.

I assume the same method can be used for Chrome, but I haven't tried it.