Net Core 2.1 无法启动,因为缺少 Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation?
Net Core 2.1 won't startup because Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation is missing?
我正在尝试启动一个较旧的 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 包,它们看起来是一样的。
我在这里监督什么?
你有 razor 文件编译的 Nuget 包吗?
如果你这样做,请尝试包括这个:
public void ConfigureServices(IServiceCollection services)
{
services.AddRazorPages()
.AddRazorRuntimeCompilation();
//your code
}
检查 nuget 包版本。不得高于 2.1
您需要从项目中删除 Razor Runtime Compilation,因为 .NET Core 2.1 不再提供 Nuget 包。
在 Startup.cs 文件的 ConfigureServices 方法中,删除任何出现的此命令:AddRazorRuntimeCompilation()
。
此外,从您的 .csproj 文件中删除对该包的任何引用。
我正在尝试启动一个较旧的 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 包,它们看起来是一样的。
我在这里监督什么?
你有 razor 文件编译的 Nuget 包吗?
如果你这样做,请尝试包括这个:
public void ConfigureServices(IServiceCollection services)
{
services.AddRazorPages()
.AddRazorRuntimeCompilation();
//your code
}
检查 nuget 包版本。不得高于 2.1
您需要从项目中删除 Razor Runtime Compilation,因为 .NET Core 2.1 不再提供 Nuget 包。
在 Startup.cs 文件的 ConfigureServices 方法中,删除任何出现的此命令:AddRazorRuntimeCompilation()
。
此外,从您的 .csproj 文件中删除对该包的任何引用。