Dabriel
Dabriel

Reputation: 503

The breakpoints aren't hit in a Blazor Webassembly project, ASP.NET Core 3.1,

The breakpoints aren't hit in a 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 haven't deployed it, I just press F5 in Visual Studio so I don't see how the code can be different.

When 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 the entries.

It worked fine until recently. The only thing I did was install Microsoft Code Analysis 2019 (I removed it again).

Upvotes: 24

Views: 28044

Answers (8)

JClarkCDS
JClarkCDS

Reputation: 419

I had this issue happen in a Blazor Server application on adding a new page component. I tried all of the above solutions and things really got worse in trying to hit the new page breakpoint. VS 2022 Version 17.6.2. After no success, I updated to VS 2022 17.6.4. Still wouldn't work. I cleaned, deleted .pdb's, closed, restarted vs, etc. many times.

Finally I thought about Excluding the component from the project, then Including the component back to the project. Rebuild and the breakpoint started working.

Upvotes: 1

Simon_Weaver
Simon_Weaver

Reputation: 145880

I literally just started using Blazor today. One of the first things I did was disable 'Launch browser' because I can't stand that behavior.

Unfortunately I just had to reenable it to get breakpoints working!

I don't yet understand enough to know if this is how I have to do it, or if there's another way.

enter image description here

Upvotes: 2

Fred
Fred

Reputation: 1221

Using Blazor and .net 5 switching from FireFox to Google Chrome did the trick for me.

Upvotes: 6

Mort
Mort

Reputation: 150

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.

Upvotes: 2

user14016210
user14016210

Reputation: 63

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.

Upvotes: 1

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.

Upvotes: 16

Praadeep
Praadeep

Reputation: 79

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

Upvotes: 3

ViRuSTriNiTy
ViRuSTriNiTy

Reputation: 5155

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.

Upvotes: 16

Related Questions