簡體   English   中英

編譯 index.cshtml 拋出運行時錯誤

[英]Compilation fo index.cshtml throws an runtime error

我正在嘗試更新一個私有的 nuget 包,對此的一些更改導致我出現了一個錯誤屏幕。

在此處輸入圖片說明

該錯誤本質上是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 may be missing. If you're seeing this in a published application, set 'CopyRefAssembliesToPublishDirectory' to true in your project file to ensure files in the refs directory are published.The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNetCore.Razor' (are you missing an assembly reference?)+[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.Views_Home_Index), @"mvc.1.0.view", @"/Views/Home/Index.cshtml")] The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNetCore.Razor' (are you missing an assembly reference?) 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 may be missing. If you're seeing this in a published application, set 'CopyRefAssembliesToPublishDirectory' to true in your project file to ensure files in the refs directory are published.The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNetCore.Razor' (are you missing an assembly reference?)+[assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.Views_Home_Index), @"mvc.1.0.view", @"/Views/Home/Index.cshtml")] The type or namespace name 'Hosting' does not exist in the namespace 'Microsoft.AspNetCore.Razor' (are you missing an assembly reference?)

我已經通過網絡嘗試了各種解決方案來完成我的功課,例如

1) 在.csproj文件中將CopyRefAssembliesToPublishDirectory'設置為true

2) Remove ASP.Net Temporary files

仍然沒有運氣。

到目前為止,我知道我嘗試打開一個網頁,當 asp.net 嘗試動態編譯時,它無法構建解決方案。

我的理解是否完整,我還能做些什么來調試和找到解決方案?

下面是一些.csproj<TargetFramework>net461</TargetFramework> <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.3" /> <PackageReference Include="System.Net.Http" Version="4.3.3" />

作為私人性質,我不能分享大部分代碼,只能分享常見的東西。

任何幫助深表感謝。

將其設置為<Project Sdk="Microsoft.NET.Sdk.Web" ToolsVersion="15.0">並包含以下文件

<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" /> <PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="2.2.0" />幫助解決問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM