Repository navigation
Improve error report on HotReloadAgent #49941
Copy link
Copy link
Closed
Labels
Pillar: Dev ExperiencePriority:1Work that is critical for the release, but we could probably ship withoutWork that is critical for the release, but we could probably ship withoutarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-hot-reloadThis issue is related to the Hot Reload feaatureThis issue is related to the Hot Reload feaature
Milestone
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Hot Reload may fail while applying code changes, see this example on applying changes while debugging in VS. I tried with .NET 7.0.203.
While the javascript stack showed useful information regarding the error:
Error: System.TypeLoadException: EnC: we do not support patching of existing table cols. token=0x0200000f
at System.Reflection.Metadata.MetadataUpdater.ApplyUpdate(:7222/Assembly assembly, ReadOnlySpan`1 metadataDelta, ReadOnlySpan`1 ilDelta, ReadOnlySpan`1 pdbDelta)
at Microsoft.Extensions.HotReload.HotReloadAgent.ApplyDeltas(:7222/IReadOnlyList`1 deltas)
at Microsoft.AspNetCore.Components.WebAssembly.HotReload.WebAssemblyHotReload.ApplyHotReloadDelta(:7222/String moduleIdString, Byte[] metadataDelta, Byte[] ilDelta, Byte[] pdbBytes)
...
This is what the user sees in the output window:
20:46 51.50 BlazorApp14.Server (Web assembly): Sending updates to running application
20:46 51.56 BlazorApp14.Server (Web assembly): [Error] Applying updates failed:
20:46 51.56 BlazorApp14.Server (Web assembly): [Error] Applying updates failed: The following error occurred when trying to apply your edits to the running application.
20:46 51.57 Exception thrown for Apply Code Updates: 0x80131500 - The following error occurred when trying to apply your edits to the running application. The following error occurred when trying to apply your edits to the running application.
20:46 51.57 Stack trace for WebToolsException:
at Microsoft.WebTools.ProjectSystem.Components.HotReload.ProjectHotReloadSession.<ApplyUpdatesAsync>d__16.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Debugger.Shared.Utilities.LoggerExtensions.<LogOnExceptionAsync>d__3.MoveNext()
20:46 51.57 An unexpected error has occurred, any pending updates have been discarded.
Problems
- The error is reported twice.
- The exception itself has the following message:
"The following error occurred when trying to apply your edits to the running application. The following error occurred when trying to apply your edits to the running application."
Proposal
We should propagate the error message back to the user. If I understand correctly, the current code only logs the error to the debug output, and not back to the user.
This is specifically for scenarios where we are applying code changes with a hot reload agent.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Pillar: Dev ExperiencePriority:1Work that is critical for the release, but we could probably ship withoutWork that is critical for the release, but we could probably ship withoutarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-hot-reloadThis issue is related to the Hot Reload feaatureThis issue is related to the Hot Reload feaature
Activity
lambdageek commentedon Aug 9, 2023
This is due to
aspnetcore/src/Components/WebAssembly/WebAssembly/src/HotReload/WebAssemblyHotReload.cs
Line 50 in 28e5590
a log callback that sends results back through the hot reload websocket would be better...
Additionally, we would ideally extend the
tryclause to also cover this lineaspnetcore/src/Components/WebAssembly/WebAssembly/src/HotReload/HotReloadAgent.cs
Line 197 in 9344b15
So that we log exceptios from
MetadataUpdater.ApplyUpdate(which Mono can throw sometimes if there are issues).captainsafia commentedon Aug 24, 2023
@isadorasophia Can you clarify what you mean by "back to the user" here?
AFAIK, the logging behavior here seems to actually be coming from VS's hot reload logic here.
6 remaining items
PreethikaSelvam commentedon Jul 22, 2026
Hi @isadorasophia,
This issue was reproducible with the reported SDK version, .NET 7.0.203. However, it could not be reproduced with later SDK versions, including .NET 8, .NET 9, and .NET 10. Based on our validation, the issue appears to have been resolved in newer releases. We recommend upgrading to the latest supported .NET SDK version to avoid encountering this issue.
oroztocil commentedon Oct 22, 2026
@PreethikaSelvam Thanks for the investigation.
Closing this issue. It only reproduced with the .NET 7 SDK, and the related code no longer exists.