aspnetcore: Hot reloading fails after the second change of a razor file

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Making a change to a .razor file no longer applies consistently after upgrading to .NET 9. I am using macOS 15.0.1 on a MacBook Pro M1 (could be related).

Expected Behavior

All changes should be hot-reloaded, not just the first one. This used to work in .NET 8.

Steps To Reproduce

  1. Create a new app by running dotnet new blazor -int Auto -o Blazor9Auto in some directory (from command prompt).
  2. Run the application dotnet watch --project Blazor9Auto/Blazor9Auto.csproj This should open the browser.
  3. Open Blazor9Auto/Components/Pages/Home.razor and change it somehow then save it. Make a few changes and save a few times. Image

Exceptions (if any)

Change failed to apply (error code: '00-00-00-00-00'). Further changes won't be applied to this process.

.NET Version

9.0.100

Anything else?

ASP.NET Core version:

9.0.0

The IDE (VS / VS Code/ VS4Mac) you’re running on, and its version:

Tested with VS Code, vim. The editor doesn’t seem to matter.

Include the output of dotnet --info:

.NET SDK:
 Version:           9.0.100
 Commit:            59db016f11
 Workload version:  9.0.100-manifests.3068a692
 MSBuild version:   17.12.7+5b8665660

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  15.0
 OS Platform: Darwin
 RID:         osx-arm64
 Base Path:   /usr/local/share/dotnet/sdk/9.0.100/

.NET workloads installed:
There are no installed workloads to display.
Configured to use loose manifests when installing new manifests.

Host:
  Version:      9.0.0
  Architecture: arm64
  Commit:       9d5a6a9aa4

.NET SDKs installed:
  6.0.406 [/usr/local/share/dotnet/sdk]
  7.0.403 [/usr/local/share/dotnet/sdk]
  8.0.403 [/usr/local/share/dotnet/sdk]
  9.0.100 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.14 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.13 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.10 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.14 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.10 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

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

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

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 18
  • Comments: 39 (13 by maintainers)

Most upvoted comments

@willdean Should be in 9.0.x. Working on a fix already.

Very concerned to see this marked as planned for .NET 10.

Is there an appreciation within MS that, for some of us, dotnet watch is unusable in 9.0 (at least for Blazor dev) and that is going to block us from moving to 9 at all?

Even the simplest (I know hot reload is not simple at all, but it used to work) stuff, like adding a class name to an element on a Blazor Server (i.e. no WASM magic) project, is now not reliably carried through to the browser. Sometimes DNW thinks there are no updates though there are, sometimes other compiler errors appear (e.g. suddenly starts thinking that components are elements and warning about that), sometimes it does update but much slower than 8.0. Sometimes the code updates but the browser has to be refreshed by hand.

Using dotnet watch for styling Blazor Server projects output was basically seamless in 8 - you could add a class, hit save and by the time you’d shifted your gaze to the other monitor the page would be updated. In 9 this has all gone. At best its slower, and mostly it’s broken.

I hoped that maybe @danroth27 had a grip on this as someone who must appreciate that the hot-reload story is utterly vital to Blazor’s success, but when I see “Net 10 Planning” appear as a milestone I wonder if we’re going to have to skip an entire release cycle.

Hello, I confirm that even with the new .NET 9 update (9.0.102) and a Blazor Server application, hot reload works two or three times and then stops working. I’m on Mac x64 with Sonoma 14.6.1.

Here are a few more tests that I conducted.

.NET 8 Blazor app with Auto interactivity

I tested an existing .NET 8 app created long before installing .NET 9 (dotnet new blazor -int Auto -o Blazor8Auto). Running the app now (with .NET 9) has the same issue. The second save of Home.razor outputs ❌ [Blazor8Auto (net8.0)] Change failed to apply (error code: '00-00-00-00-00'). Further changes won't be applied to this process..

Adding a global.json with the following content solves the problem completely:

{
  "sdk": {
    "version": "8.0.403"
  }
}

I can update Home.razor many times and the error does not appear.

.NET 9 Blazor app with Server interactivity

I then created a server interactivity app to eliminate issues related to WASM runtime loading. To do that I used dotnet new blazor -int Server -o Blazor9Server. I observed the exact same thing after saving Home.razor a second time:

➜  Blazor9Server dotnet watch
dotnet watch 🔥 Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload.
  💡 Press "Ctrl + R" to restart.
Using launch settings from /Users/korchev/github/net9/Blazor9Server/Properties/launchSettings.json...
Building...
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5243
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /Users/korchev/github/net9/Blazor9Server
warn: Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware[3]
      Failed to determine the https port for redirect.
dotnet watch ⌚ File updated: ./Components/Pages/Home.razor
dotnet watch 🔥 [Blazor9Server (net9.0)] Hot reload succeeded.
dotnet watch ⌚ File updated: ./Components/Pages/Home.razor
dotnet watch ❌ [Blazor9Server (net9.0)] Change failed to apply (error code: '00-00-00-00-00'). Further changes won't be applied to this process.

.NET 9 Blazor app without interactivity

Then I created a Blazor app without interactivity via dotnet new blazor -o Blazor9. The same error was output after the second time I updated Home.razor.

Those tests made me think that:

  1. This appears to be a regression since a .NET 8 app works just fine with a globa.json without any additional modifications (on the exact same system).
  2. The problems does not seem to be related to WASM runtime loading as apps that don’t load it fail in the exact same way.

For completeness purposes I tested on a different Mac with the same results. Also tried with different browsers - the results were the same.

Here’s mine which doesn’t sound exactly like the above, but people have added comments that do: https://github.com/dotnet/sdk/issues/44912

Here’s another which is more like mine: https://github.com/dotnet/sdk/issues/44910

Here;'s one which references Blazor: https://github.com/dotnet/sdk/issues/44384

Hi folks. Sorry about the confusion on this one. This fix did not make it in for 9.0.102, but it will be released shortly in the next .NET SDK servicing release in Feb: 9.0.103 and 9.0.200.

@timohermans I believe this fix will be in the 9.0.1 patch in Jan 9.0.103 & 9.0.200 release in Feb.

I installed the latest 9.0.300 preview with curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin -c 9.0.3xx --quality daily, which fixed the hot-reloading issues for me.

I got the same issue running on a Linux host inside a Docker container, using latest image mcr.microsoft.com/dotnet/sdk:9.0

Can confirm hot reload works again in my project 😄.

Same issue for me (works once or twice, then fails) with dotnet 9.0.102 and Mac Sequoia 15.3.

❯ dotnet watch run debug --launch-profile https
dotnet watch 🔥 Hot reload enabled. For a list of supported edits, see https://aka.ms/dotnet/hot-reload.
  💡 Press "Ctrl + R" to restart.
Using launch settings from /Users/tom/workspace/zap-middleware/tmp/blazor-samples/9.0/BlazorWebAppCallWebApi_Weather/BlazorApp/Properties/launchSettings.json...
Building...
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: https://localhost:7124
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:5236
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Development
info: Microsoft.Hosting.Lifetime[0]
      Content root path: /Users/tom/workspace/zap-middleware/tmp/blazor-samples/9.0/BlazorWebAppCallWebApi_Weather/BlazorApp
dotnet watch ⌚ File updated: ./Components/Layout/NavMenu.razor
dotnet watch 🔥 [BlazorApp (net9.0)] Hot reload succeeded.
dotnet watch ⌚ File updated: ./Components/Layout/NavMenu.razor
dotnet watch ❌ [BlazorApp (net9.0)] Change failed to apply (error code: '00-00-00-00-00'). Further changes won't be applied to this process.
dotnet watch ⌚ File updated: ./Components/Layout/NavMenu.razor
dotnet watch 🛑 Shutdown requested. Press Ctrl+C again to force exit.
info: Microsoft.Hosting.Lifetime[0]
      Application is shutting down...

dotnet watch ⌚ [BlazorApp (net9.0)] Exited

I’m not sure if I understand if this will be fixed in .NET 9.0.2 of if it’s already live in 9.0.1, but I still have the “Change failed to apply (error code: ‘00-00-00-00-00’). Further changes won’t be applied to this process.” error when I try to make a change in a .NET 8 project. Am I missing something?

fwiw, I had similar issues on Ubuntu 20.04 using a .net 9 version I built from source several weeks ago. It happened on a Blazor project that does not use WASM, just Blazor Server with HTMX on the client. Kept running into “Change failed to apply (error code: ‘…’)…” messages.

I know Ubuntu 20 is not supported on dotnet 9, and thought maybe it’s something just on my environment, but now I see that it’s in other platforms as well

I’m running Ubuntu 24.04 with the latest .NET 9.0 version and am facing the exact same issues