Compiler threw an exception after making changes to razor view and page reload
ASP.NET CORE 2.20
Created a boilerplate ASP.NET CORE web app project, use kestrel as the web server run without debugging, then making changes to the razor view of the default page being loaded and try to reload the page from the browser. The error I got was
An unhandled exception occurred while processing the request. MissingMethodException: Method not found: 'Microsoft.Cci.IMethodReference Microsoft.Cci.ICustomAttribute.Constructor(Microsoft.CodeAnalysis.Emit.EmitContext)'.
--STACK TRACE----
Microsoft.CodeAnalysis.CSharp.Symbol.Microsoft.CodeAnalysis.ISymbol.GetAttributes()
Microsoft.CodeAnalysis.Razor.DefaultTagHelperDescriptorFactory.GetAccessibleProperties(INamedTypeSymbol typeSymbol)
Microsoft.CodeAnalysis.Razor.DefaultTagHelperDescriptorFactory.AddBoundAttributes(INamedTypeSymbol type, TagHelperDescriptorBuilder builder)
Microsoft.CodeAnalysis.Razor.DefaultTagHelperDescriptorFactory.CreateDescriptor(INamedTypeSymbol type)
Microsoft.CodeAnalysis.Razor.DefaultTagHelperDescriptorProvider.Execute(TagHelperDescriptorProviderContext context)
Microsoft.CodeAnalysis.Razor.CompilationTagHelperFeature.GetDescriptors()
Microsoft.AspNetCore.Razor.Language.DefaultRazorTagHelperBinderPhase.ExecuteCore(RazorCodeDocument codeDocument)
Microsoft.AspNetCore.Razor.Language.RazorEnginePhaseBase.Execute(RazorCodeDocument codeDocument)
Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument document)
Microsoft.AspNetCore.Razor.Language.DefaultRazorProjectEngine.ProcessCore(RazorCodeDocument codeDocument)
Microsoft.AspNetCore.Razor.Language.RazorProjectEngine.Process(RazorProjectItem projectItem)
Microsoft.AspNetCore.Mvc.Razor.Internal.RazorViewCompiler.CompileAndEmit(string relativePath)
Microsoft.AspNetCore.Mvc.Razor.Internal.RazorViewCompiler.OnCacheMiss(string normalizedPath)
Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorPageFactoryProvider.CreateFactory(string relativePath)
Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.CreateCacheResult(HashSet
CC @rynowak
Given the exception here is MissingMethodException this would suggest a deployment issue vs. a compiler bug. Have you all seen this before?
No, I have not seen this before, and I agree with the assessment. This should be using 2.8.0 of Microsoft.CodeAnalysis.CSharp with all its dependencies brought in transitively.
Just to clarify for anyone else who stumbles onto this like I did, downgrade the reference to Microsoft.CodeAnalysis.Common from v2.10.0 to v2.8.0 and the problem should be fixed.
downgrade the reference to Microsoft.CodeAnalysis.Common from v2.10.0 to v2.8.0
We were experiencing this same issue, downgrading worked :)