'Unable to Hot Reload on Visual Studio 2022
I moved my web app from Visual Studio 2019 to 2022 (Preview 7) but I am unable to hot-reload even small changes like changing if(a=b) to if(a!=b) and will require stopping the debugger, and I am unsure what is the 'COMPLUS_ForceENC' environment variable, couldn't find anything about it.
When I create a new web app, hot reload works very well on C# and cshtml.
this is the error shown when I change anything to my original app:
Error ENC2004: Changes made in project require restarting the application: Changes are not allowed when the debugger has been attached to an already running process. Consider setting 'COMPLUS_ForceENC' environment variable before launching your process.
Solution 1:[1]
I was blaming VS for un-functional Hot Reload, but in my case it was caused by trying to Debug ( F5 ) and hot reloading at the same time. Hot reload icon
did not work at all for blazor apps.
The solution was quite simple. The app needs to be started without debugging ( Ctrl+F5 ) 
After that hot reload works fine.
Solution 2:[2]
Might be a coincidence, but after updating from 17.0.1 to 17.0.2 it started working. It's strange because in the update log there's no mention to such a bug fix. Try updating to the latest version.
UPDATE Seems that I only got this working on my new .NET 6 project. In the old one migrated to .NET 6 this still happens. Maybe in projects that are not fully migrated to .NET 6 and still using the old startup.cs file won't work correctly. In debug mode, the update notification shows up, but content does not change until a browser refresh.If not in debug mode, refreshing the browser does nothing.
UPDATE 2 Found out that in a new .net 6 Asp.net Web page project, the Hot reload works well if I change .razor files, but in .cshtml files I need to refresh the browser to see changes. I have both file types because I'm using razor pages + Blazor in the same project.
If you try to create a .Net 6 Blazor project I'm almost sure Hot Reload will work.
UPDATE 3 I have now opened an Issue in Dotnet Github. You can follow the issue there. github.com/dotnet/aspnetcore/issues/38809
Solution 3:[3]
VisualStudio 2022 GA version doesn't works for me either :( looks i'm not the only one, i've noticed i've a icon for the hot reload function different from the one shown in the Microsoft promotional videos, mine is a flame, while the working version seems to have two flames that forms a circle :(
i've found this
*In Visual Studio 2022 GA release Hot Reload support for Blazor WebAssembly when using the Visual Studio debugger isn’t enabled yet. You can still get Hot Reload If you start your app through Visual Studio without the debugger, and we are working to resolve this in the next Visual Studio update.
if i start the program without debugger attached I have Hot Reload, or i can run the app with the debugger without the hot reload, which is expected by the article linked above but the Launch Event is quite misleading as they never mention this nor shown which button is pressed during the demos to start blazor webasm with hot reload working... Anyway they doesn't show debugger and hot reload working together for blazor webasm, so it looks like it's all in our minds :( ... we need to wait
Solution 4:[4]
In my case I made a stupid mistake of trying to Hot Reload an application run in Release configuration. Make sure it is Debug :)
Solution 5:[5]
In my case, it was due to I have disabled Razor Source Generator <UseRazorSourceGenerator>false</UseRazorSourceGenerator> in the .csproj file. Setting it back to true fixed the issue.
Solution 6:[6]
Might help someone. I removed reference to Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation in my Web project and code in my startup and HotReload working now...
Solution 7:[7]
It's a common issue for Preview users. Now you can update for the stable release and enjoy the full features including Hot reload.
Please visit https://visualstudio.microsoft.com/ to download the stable VS 2022 editions
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | walter33 |
| Solution 2 | |
| Solution 3 | |
| Solution 4 | Robert Synoradzki |
| Solution 5 | Noctis Tong |
| Solution 6 | Tim Maxey |
| Solution 7 | AG Mohammed |

