编译处理此请求所需的资源时发生错误 (ASP.NETCore MVC)
An error occurred during the compilation of a resource required to process this request (ASP.NETCore MVC)
我正在开发一个 ASP NETCore MVC 应用程序并且一切正常,但突然我遇到了一个巨大的错误,不是在编译时,而是在我尝试访问网站时:
An error occurred during the compilation of a resource required to process this request. Please review the following specific error details and modify your source code appropriately.
Generated Code
One or more compilation references are missing. Ensure that your project is referencing 'Microsoft.NET.Sdk.Web' and the 'PreserveCompilationContext' property is not set to false.
The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
4.[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/Views/Debug/Index.cshtml", typeof(AspNetCore._Views_Debug_Index_cshtml))]
Predefined type 'System.String' is not defined or imported
4.[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/Views/Debug/Index.cshtml", typeof(AspNetCore._Views_Debug_Index_cshtml))]
Predefined type 'System.Type' is not defined or imported
4.[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/Views/Debug/Index.cshtml", typeof(AspNetCore._Views_Debug_Index_cshtml))]
Predefined type 'System.Void' is not defined or imported
4.[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/Views/Debug/Index.cshtml", typeof(AspNetCore._Views_Debug_Index_cshtml))]
The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
8. using System;
The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
9. using System.Collections.Generic;
The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
10. using System.Linq;
The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
11. using System.Threading.Tasks;
The type or namespace name 'ViewFeatures' does not exist in the namespace 'Microsoft.AspNetCore.Mvc' (are you missing an assembly reference?)
14. using Microsoft.AspNetCore.Mvc.ViewFeatures;
Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute' cannot be found. Are you missing a reference?
40. public class _Views_Debug_Index_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic>
而这只是浏览器显示错误的一小部分。
有什么想法吗?
谢谢
我创建了一个新项目并将所有文件移入其中,并且它起作用了,也许不是最好的解决方案,但好吧,它起作用了。
我正在开发一个 ASP NETCore MVC 应用程序并且一切正常,但突然我遇到了一个巨大的错误,不是在编译时,而是在我尝试访问网站时:
An error occurred during the compilation of a resource required to process this request. Please review the following specific error details and modify your source code appropriately.
Generated Code
One or more compilation references are missing. Ensure that your project is referencing 'Microsoft.NET.Sdk.Web' and the 'PreserveCompilationContext' property is not set to false.
The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
4.[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/Views/Debug/Index.cshtml", typeof(AspNetCore._Views_Debug_Index_cshtml))]
Predefined type 'System.String' is not defined or imported
4.[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/Views/Debug/Index.cshtml", typeof(AspNetCore._Views_Debug_Index_cshtml))]
Predefined type 'System.Type' is not defined or imported
4.[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/Views/Debug/Index.cshtml", typeof(AspNetCore._Views_Debug_Index_cshtml))]
Predefined type 'System.Void' is not defined or imported
4.[assembly:global::Microsoft.AspNetCore.Mvc.Razor.Compilation.RazorViewAttribute(@"/Views/Debug/Index.cshtml", typeof(AspNetCore._Views_Debug_Index_cshtml))]
The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
8. using System;
The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
9. using System.Collections.Generic;
The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
10. using System.Linq;
The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
11. using System.Threading.Tasks;
The type or namespace name 'ViewFeatures' does not exist in the namespace 'Microsoft.AspNetCore.Mvc' (are you missing an assembly reference?)
14. using Microsoft.AspNetCore.Mvc.ViewFeatures;
Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute' cannot be found. Are you missing a reference?
40. public class _Views_Debug_Index_cshtml : global::Microsoft.AspNetCore.Mvc.Razor.RazorPage<dynamic>
而这只是浏览器显示错误的一小部分。 有什么想法吗?
谢谢
我创建了一个新项目并将所有文件移入其中,并且它起作用了,也许不是最好的解决方案,但好吧,它起作用了。