roslyn icon indicating copy to clipboard operation
roslyn copied to clipboard

Compiler threw an exception after making changes to razor view and page reload

Open huzaynbolt opened this issue 7 years ago • 5 comments

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)'.

huzaynbolt avatar Dec 22 '18 10:12 huzaynbolt

--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 expirationTokens, string relativePath, bool isMainPage) Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.OnCacheMiss(ViewLocationExpanderContext expanderContext, ViewLocationCacheKey cacheKey) Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.LocatePageFromViewLocations(ActionContext actionContext, string pageName, bool isMainPage) Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.FindView(ActionContext context, string viewName, bool isMainPage) Microsoft.AspNetCore.Mvc.ViewEngines.CompositeViewEngine.FindView(ActionContext context, string viewName, bool isMainPage) Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.FindView(ActionContext actionContext, ViewResult viewResult) Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor.ExecuteAsync(ActionContext context, ViewResult result) Microsoft.AspNetCore.Mvc.ViewResult.ExecuteResultAsync(ActionContext context) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultAsync(IActionResult result) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResultFilterAsync<TFilter, TFilterAsync>() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.ResultNext<TFilter, TFilterAsync>(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeResultFilters() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync() Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync() Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware.Invoke(HttpContext context) Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext) Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

huzaynbolt avatar Dec 22 '18 10:12 huzaynbolt

CC @rynowak

Given the exception here is MissingMethodException this would suggest a deployment issue vs. a compiler bug. Have you all seen this before?

jaredpar avatar Jan 02 '19 16:01 jaredpar

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.

rynowak avatar Jan 02 '19 22:01 rynowak

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.

mikefayer avatar Feb 19 '19 13:02 mikefayer

downgrade the reference to Microsoft.CodeAnalysis.Common from v2.10.0 to v2.8.0

We were experiencing this same issue, downgrading worked :)

JohnCOsborne avatar Aug 22 '19 11:08 JohnCOsborne