Home > other >  Net Core 2.1 won't startup because Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation is missing
Net Core 2.1 won't startup because Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation is missing

Time:01-25

I am trying to start an older ASP NET Core 2.1 project without any luck. I constantly get the following error during startup:

    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)

I have other 2.1 projects without any problems. I compared all settings and NuGet packages, they look equal.

What do I oversee here?

CodePudding user response:

Do you have the Nuget package for the razor file compilation?

If you do, try including this:

public void ConfigureServices(IServiceCollection services)
    {
        services.AddRazorPages()
            .AddRazorRuntimeCompilation();
    
        //your code
    }

CodePudding user response:

Check nuget package versions. They must not be higher than 2.1

  •  Tags:  
  • Related