Unbound Breakpoints in Blazor WASM Project
Asked Answered
P

5

13

I am unable to debug a WASM project in VS 2022, v17.3.6 do to unbound breakpoints. The breakpoints look fine when not running but become an empty circle with the warning sign inside when running the project. The message is “The breakpoint will not currently be hit. Unbound breakpoint”. Other projects within the same solution can be debugged. Three developers on the team have this issue, one does not. All are now on the same version of VS. We tried a slightly older version of VS 2022 (v17.3.4) and it also had this problem.

Below are several ways I tried to fix the problem using many of the suggestions from other posts.

Peebles answered 26/10, 2022 at 17:35 Comment(2)
I have had similar issues and sometimes opening the javascript console in the browser helps. Not very practical though.Coray
Hey guys. In my case I was just in Release mode. So switching from Release to Debug fixed the problemOptics
R
5

The solution in this case had to do with HTTPS. The developers exhibiting the problem (well, 2 out of 3 of them) have a persistent problem when they launch the app, where ASPNET pops up wanting to install a development certificate. They click yes, and it pops up and says it was unsuccessful. This is annoying but otherwise not something the devs worry about since it's been an ongoing annoyance for months if not years.

We tried many things to troubleshoot the problem, including creating a new Blazor WebAssembly project on the machine that couldn't debug. We were able to debug the brand new project! Upon closer examination, we saw that it was created with no authentication. Creating a second project with Individual User Accounts exhibited the same behavior as the production app - breakpoints could not be bound. While tearing apart the code in the non-working new project (with auth) we finally looked at the two launchSettings.json files and found that one of them had two application URLs (https://localhost:XXXX;http://localhost:XXXY), while the other had only the http URL. We deleted the https URL and suddenly the project could be debugged (and the annoying cert popup disappeared, naturally).

We made the same change in the production solution, removing the https application url, and we were able to debug once more. This fixed all three team members who had been unable to debug. Troubleshooting this issue took at least a dozen developer hours and slowed development for several calendar weeks while the team worked around it, so hopefully this helps someone else with the same issue.

Reprehend answered 27/10, 2022 at 18:23 Comment(3)
What version of VS2022 are you using?Binky
I cannot wait to try this at home, have you found a work around for https?Maladjusted
This article covers HTTPS in general for ASP.NET Core. Not a Blazor help doc, but was linked from the Blazor docs. learn.microsoft.com/en-us/aspnet/core/security/…Acuna
L
2

I recently ran into this exact same issue, but wanted to maintain the ability to run under https protocol. Somewhere along the way, I must have had an issue installing the certificate as well. Removing the local dev certs and adding them again solved my issue. Client breakpoints hit after using a proper dev cert. Hoping this can help someone else stuck in the same predicament.

Too erase and add certs:

dotnet dev-certs https --clean
dotnet dev-certs https --trust 
Lowerclassman answered 31/10, 2023 at 18:21 Comment(0)
I
0

I've had the same problem, breakpoint wasn't being hit when I was using 'dotnet watch' launch profile. I was able to start debugging after changing the launch profile back to the launch profile with a commandName: 'Project'.

Imena answered 26/10, 2022 at 20:5 Comment(1)
Is this with automatically opening a browser window? That's all that works for me and I hate it lol.Acuna
A
0

I'm very new to Blazor and I still don't really know how all the debugging pieces 'fit together'.

It's worth going through these docs below.

  1. I didn't have Javascript debugging enabled.
  2. My dev certificate seemed to have expired literally today.

https://learn.microsoft.com/en-us/aspnet/core/blazor/debug?view=aspnetcore-7.0&tabs=visual-studio

https://learn.microsoft.com/en-us/aspnet/core/security/enforcing-ssl?view=aspnetcore-7.0&tabs=visual-studio%2Clinux-ubuntu#troubleshoot-certificate-problems-such-as-certificate-not-trusted

One other thing is I can't seem to get it to work reliably unless 'Launch Browser' is set to automatically launch. This is under the 'Launch Profiles'.

Enabling this option allowed me to debug right away. I assume it's something to do with launching Edge in debugging mode, but manually launching in debugging mode doesn't work.

enter image description here

I personally absolutely hate having this turned on. I don't want browser windows opening every time I hit F5. Until I understand how it all works this at least lets me debug.

Acuna answered 15/6, 2023 at 5:24 Comment(0)
C
0

My unbound breakpoints fiasco happened because I unintentionally referenced

<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.13" PrivateAssets="all">

…in my Blazor WASM .csproj file while updating some packages.

Since I target .NET 6 in the app, the project would run fine, but with no breakpoint support. Reverting back to:

<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.22" PrivateAssets="all">

…resolved my issue nicely.

Cheshvan answered 15/11, 2023 at 1:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.