我正在嘗試啟動一個較舊的 ASP NET Core 2.1 專案,但沒有任何運氣。我在啟動程序中不斷收到以下錯誤:
Microsoft.AspNetCore.Hosting.Internal.WebHost[11]
Hosting startup assembly exception
System.InvalidOperationException: Startup assembly Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation failed to execute. See the inner exception for more details. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation, Culture=neutral, PublicKeyToken=null'. Das System kann die angegebene Datei nicht finden.
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, IntPtr ptrLoadContextBinder)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
我還有其他 2.1 專案沒有任何問題。我比較了所有設定和 NuGet 包,它們看起來相同。
我在這里監督什么?
uj5u.com熱心網友回復:
您需要從專案中洗掉 Razor 運行時編譯,因為 Nuget 包不再適用于 .NET Core 2.1。
在 Startup.cs 檔案的 ConfigureServices 方法中,洗掉任何出現的以下命令:AddRazorRuntimeCompilation()。
此外,從 .csproj 檔案中洗掉對包的任何參考。
uj5u.com熱心網友回復:
你有用于 Razor 檔案編譯的 Nuget 包嗎?
如果這樣做,請嘗試包括以下內容:
public void ConfigureServices(IServiceCollection services)
{
services.AddRazorPages()
.AddRazorRuntimeCompilation();
//your code
}
uj5u.com熱心網友回復:
檢查 nuget 包版本。它們不得高于 2.1
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/422436.html
標籤:
上一篇:HTTP客戶端方法空例外
