9

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.

  • I have had similar issues and sometimes opening the javascript console in the browser helps. Not very practical though. – lucuma Oct 26 '22 at 17:51
  • Hey guys. In my case I was just in Release mode. So switching from Release to Debug fixed the problem – Allaev Bekzod Jan 31 '23 at 18:56

3 Answers3

4

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.

ssmith
  • 8,092
  • 6
  • 52
  • 93
  • What version of VS2022 are you using? – MC9000 Nov 17 '22 at 05:49
  • I cannot wait to try this at home, have you found a work around for https? – Skuffd Jan 05 '23 at 14:07
  • This article covers HTTPS in general for ASP.NET Core. Not a Blazor help doc, but was linked from the Blazor docs. 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 – Simon_Weaver Jun 15 '23 at 05:25
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'.

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.

Simon_Weaver
  • 140,023
  • 84
  • 646
  • 689