'Trying to Edit and Continue on a cshtml file is always throwing an exception
When I make any change to a CSHTML file while debugging then reload the page, I get this exception. This used to work, and I'm not aware of any changes that could affect this. Googling this error message hasn't been helpful either. Any direction is very much appreciated.
I have tried all the suggestions in https://stackoverflow.com/a/27672935/3397630 without any luck.
I am currently using Visual Studio Community 2022 and .NET 5, but this same thing was happening with 2019.
An unhandled exception occurred while processing the request.
MissingMethodException: Method not found: 'Void Microsoft.CodeAnalysis.CompilationOptions.set_ReferencesSupersedeLowerVersions_internal_protected_set(Boolean)'.
Microsoft.CodeAnalysis.CSharp.CSharpCompilationOptions.WithReferencesSupersedeLowerVersions(bool value)
TypeInitializationException: The type initializer for 'Microsoft.CodeAnalysis.CSharp.CSharpCompilation' threw an exception.
Microsoft.CodeAnalysis.Razor.CompilationTagHelperFeature.GetDescriptors()
Solution 1:[1]
It sounds like you may need to enable runtime compilation of Razor files: https://docs.microsoft.com/en-us/aspnet/core/mvc/views/view-compilation?view=aspnetcore-5.0&tabs=visual-studio
See also: .NET Core 3.0: Razor views don't automatically recompile on change
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 |