Skip to content

dotnet watch crash with Aspire and BlazorWASM #48924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Dona278 opened this issue May 7, 2025 · 3 comments
Closed

dotnet watch crash with Aspire and BlazorWASM #48924

Dona278 opened this issue May 7, 2025 · 3 comments
Assignees

Comments

@Dona278
Copy link

Dona278 commented May 7, 2025

Description

We have a solution with Aspire which worked well with dotnet watch command until net9 (net8 never thrown exception).
Today after some attempts on try to reproduce with less projects as possibile we discovered that the exception was thrown if the Aspire project has at least one reference to a Blazor project.

Blazor project is a hosted wasm model so the referenced project is the "WebServer (aspnetcore)" and not directly the "Web (blazor wasm)".

System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.DotNet.Watch.BlazorWebAssemblyDeltaApplier.ApplyManagedCodeUpdates(ImmutableArray`1 updates, CancellationToken cancellationToken)
   at Microsoft.DotNet.Watch.BlazorWebAssemblyHostedDeltaApplier.ApplyManagedCodeUpdates(ImmutableArray`1 updates, CancellationToken cancellationToken)
   at Microsoft.DotNet.Watch.CompilationHandler.<>c__DisplayClass19_0.<<HandleManagedCodeChangesAsync>b__2>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.DotNet.Watch.CompilationHandler.HandleManagedCodeChangesAsync(Func`3 restartPrompt, CancellationToken cancellationToken)
   at Microsoft.DotNet.Watch.HotReloadDotNetWatcher.WatchAsync(CancellationToken shutdownCancellationToken)
   at Microsoft.DotNet.Watch.HotReloadDotNetWatcher.WatchAsync(CancellationToken shutdownCancellationToken)
   at Microsoft.DotNet.Watch.HotReloadDotNetWatcher.WatchAsync(CancellationToken shutdownCancellationToken)
   at Microsoft.DotNet.Watch.Program.RunAsync()
dotnet watch ❌ An unexpected error occurred

Reproduction Steps

  • Solution with Aspire host, some references to services (aspnetcore) and a blazor-hosted-wasm project
  • Run dotnet watch from aspire host project
  • Made a change in one random file
  • See hotreload logs in console (some services write hot reload success) and then the exception

Expected behavior

Work without errors

Actual behavior

After made a change on any file of any project the command throw exception

Regression?

No response

Known Workarounds

If we remove the reference to the blazor project the command works like a charm.
So for now we launch aspire with watch and blazor projects with watch as well but each into separated VS or terminal..

Configuration

.NET SDK:
Version: 9.0.300-preview.0.25177.5
Commit: 3d5b396
Workload version: 9.0.300-manifests.78a0f7ac
MSBuild version: 17.14.0-preview-25175-08+5880e1c75

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26100
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.300-preview.0.25177.5\

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

Host:
Version: 9.0.4
Architecture: x64
Commit: f57e6dc747

.NET SDKs installed:
9.0.203 [C:\Program Files\dotnet\sdk]
9.0.300-preview.0.25177.5 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other information

No response

@dotnet-policy-service dotnet-policy-service bot added the untriaged Request triage from a team member label May 7, 2025
@dotnet-policy-service dotnet-policy-service bot removed the untriaged Request triage from a team member label May 7, 2025
@tommcdon tommcdon transferred this issue from dotnet/runtime May 13, 2025
@dotnet-policy-service dotnet-policy-service bot added the untriaged Request triage from a team member label May 13, 2025
@lewing
Copy link
Member

lewing commented May 15, 2025

cc @tmat

@tmat
Copy link
Member

tmat commented May 15, 2025

Looks like issue fixed by #48909

@tmat
Copy link
Member

tmat commented May 15, 2025

Duplicate of #48898

@tmat tmat marked this as a duplicate of #48898 May 15, 2025
@tmat tmat closed this as completed May 15, 2025
@dotnet-policy-service dotnet-policy-service bot removed the untriaged Request triage from a team member label May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants