aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

.NET 8 Blazor WASM Debugging and Hot Reload are very buggy.

Open DuckScapePhilip opened this issue 1 year ago • 16 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Describe the bug

I have a Blazor WASM project that I developed in .NET 7 where the debugger worked great and the hot reload worked well enough, but never great, mostly, every once in a while, I would have to close VS 2022 and re-open to get the hot reload to work.

Since I upgraded to .NET 8 the debugger and the hot reload are pretty much broken.

  1. The debugger will work sometimes, maybe 30% of the time but:

    • VS 2022 will freeze for 30 seconds to 1 minute and then respond. It does this every so often.
    • The debugger will get stuck stopping on a break point. I will set a break point, it will stop there, I will hit Continue and it just keeps stopping there, even when I take the break point away.
    • Maybe 25% of the time, I will get these break points in a dynamic java script file that says Source content not found. and it will keep stopping my debugger until I close the dynamic file.
  2. The Hot Reload doesn't even work enough for me to use it.

    • Can make a change and it will still say "No changes were found." - Even something as simple as adding a class to an HTML element.
    • Can make a change and it will apply the change and then crash with:
    19:25 51.68 XXXXXXX (Web assembly): Hot reload session started
    19:27 50.64 Checking for updates...
    19:28 05.40 Applying updates...
    19:28 05.41 XXXXXXX (Web assembly): Sending updates to running application
    19:28 15.48 XXXXXXX (Web assembly): [Error] Applying updates to the application failed. A task was canceled. A task was canceled.
    19:28 15.48 Exception thrown for Apply code updates: 0x80131500 - A task was canceled.
    19:28 15.49 An unexpected error has occurred, any pending updates have been discarded.
    

I have spent a few hours looking on the internet for information and fixes and reports from other people, but nothing has worked so far.

I would really appreciate some help on this, because without these two features, development is incredibly slow and painful.

Expected Behavior

  1. The debugger does not freeze VS every time I startup the app.
  2. The debugger does not repeatedly stop on a breakpoint even after I press continue.
  3. The debugger does not stop on break points when they have been removed.
  4. The debugger does not break on random dynamic JavaScript.
  5. The hot reload functions.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

8.0.102

Anything else?

.NET SDK: Version: 8.0.102 Commit: 64f1bc458e Workload version: 8.0.100-manifests.8a11730e

Runtime Environment: OS Name: Windows OS Version: 10.0.22631 OS Platform: Windows RID: win-x64 Base Path: C:\Program Files\dotnet\sdk\8.0.102\

.NET workloads installed: Workload version: 8.0.100-manifests.8a11730e [maui-windows] Installation Source: VS 17.8.34601.278 Manifest Version: 8.0.6/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maui\8.0.6\WorkloadManifest.json Install Type: Msi

[maccatalyst] Installation Source: VS 17.8.34601.278 Manifest Version: 17.2.8004/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.maccatalyst\17.2.8004\WorkloadManifest.json Install Type: Msi

[ios] Installation Source: VS 17.8.34601.278 Manifest Version: 17.2.8004/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.ios\17.2.8004\WorkloadManifest.json Install Type: Msi

[android] Installation Source: VS 17.8.34601.278 Manifest Version: 34.0.43/8.0.100 Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.android\34.0.43\WorkloadManifest.json Install Type: Msi

Host: Version: 8.0.2 Architecture: x64 Commit: 1381d5ebd2

.NET SDKs installed: 8.0.102 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.27 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 8.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found: x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables: Not set

global.json file: Not found

Learn more: https://aka.ms/dotnet/info

Download .NET: https://aka.ms/dotnet/download

DuckScapePhilip avatar Feb 16 '24 19:02 DuckScapePhilip

I confirm this. I am using the latest version of VS and I spend more time doing these tasks than writing actual code.

*Starting the project (especially in debug mode). This is understandable since it is creating a binary.

  • Stopping project , waiting for "Script Documents" Node in Solution explorer to remove the nodes one by one
  • Sometimes I have to repeat these because VS opens a blank page because there is some previous process not closed properly.
  • Hot Reloads works a few times, then I have to close and reopen VS
  • Sometimes the process just dont stop when I try to stop the Debug session. (even if I close the process manually) Then I have to end Visual Studio's process from Task Manager

HolyOne avatar Feb 17 '24 02:02 HolyOne

thanks

ersanyakit avatar Feb 17 '24 03:02 ersanyakit

@DuckScapePhilip thanks for contacting us.

Can you file an issue through the report a problem dialog in visual studio? https://learn.microsoft.com/en-us/visualstudio/ide/how-to-report-a-problem-with-visual-studio?view=vs-2022

That will take care of capturing all the information we might need to troubleshoot and debug the issue.

Please link the new issue here so that we can keep track of it.

javiercn avatar Feb 20 '24 09:02 javiercn

Okay, I will do that. Thanks!

DuckScapePhilip avatar Feb 23 '24 15:02 DuckScapePhilip

I'm experiencing the same problem in Visual Studio 2022 (Version 17.9.0) .NET 8 Blazor WASM app.

rahul7720 avatar Feb 25 '24 16:02 rahul7720

Our whole team is experiencing similar issues. It is a major dealbreaker for us, debugging and hot reload must work reliably for modern app development.
I recommend to make this a top 1 priority.

Stra1ghter avatar Feb 26 '24 09:02 Stra1ghter

The debugger slowing and hanging is a visual studio issue (that is tracked here). Other people in my team using Rider or VS Code do not have this issue. It is reported as fixed and will be released in version 17.10 of Visual Studio.

Hot reload is a different beast however. It almost never worked for me too. Sure it works if I create a new blazor web app project, that has a few components and references, but when trying to use it in a solution with many projects and components with complex inheritance trees (that are .cs) then it is unusable.

stavroskasidis avatar Mar 12 '24 18:03 stavroskasidis

I'm experiencing the same problem in Visual Studio 2022 (Version 17.9.2) .NET 8 Blazor WASM app. Hot reload almost never Debugging not working properly

JirkabAion avatar Mar 13 '24 15:03 JirkabAion

Also seeing Hot Reload issues with both Blazor WASM and Server. on .NET 8.0.201.

Currently running into an issue where updating the grid-template-columns style property of an element causes the whole element to be deleted when Hot Reload kicks in. We need to restart the app for the changes to take effect. It makes working in Blazor extremely frustrating since we need to constantly get back to where we were after making random UI changes.

UniMichael avatar Mar 14 '24 13:03 UniMichael

I'm have issues as well when trying to run in Debug mode, every time I stop debugging mode I have to wait 1-2 minutes and then I will get this message to stop now, clicking stop now takes another 30 seconds or so before I can start coding again! Very frustrating when I need to start and stop several times in a day, losing so much time on this! Was not an issue until I upgraded to the latest Visual Studio, and .NET 8 latest versions.

VS ERROR

RickBenz avatar Apr 30 '24 17:04 RickBenz

I have the same issues. I just started developing using .NET and it's just baffling to me how unstable and unreliable even such basic features seem to be, having proper hot reloading for many years with frontend frameworks like React and Vue.

linkurzweg avatar May 14 '24 09:05 linkurzweg

I have the same issues. I just started developing using .NET and it's just baffling to me how unstable and unreliable even such basic features seem to be, having proper hot reloading for many years with frontend frameworks like React and Vue.

I have given up on hot reload. It does not work when the project has a moderate size or bigger (e.g. having many libraries with components with multiple levels of inheritance).

stavroskasidis avatar May 14 '24 09:05 stavroskasidis

I also have issues when I add a new page to a shared library, hot reload works but the new page gives 404. I could see the page after dotnet clean and dotnet watch.

HolyOne avatar May 22 '24 16:05 HolyOne

Same problem here, updated old hosted WASM to .net 8, and not a single breakpoint works anymore...

emorell96 avatar Jun 03 '24 09:06 emorell96

This is driving me crazy. It was (mostly) working a month ago. Now after updating to VS 17.10 and v8.0.300 SDK I am plagued with problems debugging a hosted WASM app. It breaks in the debugger where there are no breakpoints. In fact it is breaking in code imported through PackageReference. So not even my code!

I have been developing professionally for about 28 years now, starting with VB3 back in the 90's and I do not think I have ever been as frustrated as I am right now. Time to check out Rider?

hellfirehd avatar Jun 06 '24 16:06 hellfirehd

I just got our, pretty huge, code-base working with Hot Reload again, after 4-5 months of it hardly working at all, and it might be worth it for someone to read.

I opened our solution in "Rider", just to check if it would work better there. But before I could even get it running I had several syntax- and reference-errors popping up in Rider. I went through them, removed extra unwanted semi-colons, some using aliases that apparently were in conflict and one component parameter that it could not parse. After those fixes I started the solution in VS 2022 again, and Hot Reload suddenly worked "flawlessly" (i.e. as it did previously - by no means perfect, but minor changes to razor/css/js usually works now).

Now I am a bit worried that VS has not picked up on these errors. Apparently it could still compile and run, but Hot reload and debugging was not working as expected.

MJohnsson avatar Jun 24 '24 11:06 MJohnsson

I have been unable to debug after migrating to .NET 8 WebAssembly, and struggled way too long with this.

I finally found the (now obvious) problem, and thought I might share. For my .Server project the launchSettings.json (located in the Properties) was having a wrong inspectUri, which happened to be the old one before migration. I replaced the launchSettings.json with the one from the Blazor WebAssembly Template and debugging started to work again:

{
  "$schema": "http://json.schemastore.org/launchsettings.json",
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:44900",
      "sslPort": 44300
    }
  },
  "profiles": {
    "http": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
      "applicationUrl": "http://localhost:5262",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "https": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
      "applicationUrl": "https://localhost:7046;http://localhost:5262",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

bytefish avatar Jul 17 '24 08:07 bytefish