The solution would be to downgrade the Microsoft.AspNetCore.Identity nuget package to 3.1.0 instead of 3.1.1 then the error should go away.
Good luck!
ASP.NET Core 3.1.0 site won't run - Could not load Microsoft.AspNetCore.Razor.Runtime, Version=3.1.1.0
I'm building an ASP.NET Core app, and it's stored on an Azure web service.
I had just finished the tutorial on connecting to a SQL server and was beginning to set up the ASP.NET Core Identity stuff on there. However, whenever I deployed my site up to the Azure web service, I kept getting an error and it wouldn't load.
The error only started after I deployed the changes involving the SQL Server and identity stuff, and with the logs, it's clear that it's getting through the SQL Server bit of it just fine.
According to the logs, the error is in the Startup.cs file, at the line:
services.AddDefaultIdentity(options => options.SignIn.RequireConfirmedAccount = true).AddEntityFrameworkStores();
(the code line doesn't seem to be displaying properly in this text editor, please use the screenshot below for the actual code line. I'll also post the full text log below.)
It appears to me that it's attempting to load a 3.1.1 version of a base library, but only ASP.NET Core 3.1.0 is actually on Azure. Me downgrading the NuGet package of Microsoft.AspNetCore.Identity.UI from 3.1.1 to 3.1.0 seems to confirm this, as the website appears to be functional in Azure when I do so.
The options in the Azure portal don't seem to give a way for me to specify loading ASP.NET Core 3.1.1 for my app, only 3.1.0; is there any way to make this issue not happen without having to downgrade everything on my end to a lower version of ASP.NET Core?
Here is the full text log/stack trace:
2020-01-31T05:45:55.246568495Z _____
2020-01-31T05:45:55.246609196Z / _ \ __________ _________ ____
2020-01-31T05:45:55.246615596Z / /_\ \___ / | \_ __ \_/ __ \
2020-01-31T05:45:55.246620296Z / | \/ /| | /| | \/\ ___/
2020-01-31T05:45:55.246624796Z \____|__ /_____ \____/ |__| \___ >
2020-01-31T05:45:55.246629497Z \/ \/ \/
2020-01-31T05:45:55.246633897Z A P P S E R V I C E O N L I N U X
2020-01-31T05:45:55.246638197Z
2020-01-31T05:45:55.246642297Z Documentation: http://aka.ms/webapp-linux
2020-01-31T05:45:55.246646497Z Dotnet quickstart: https://aka.ms/dotnet-qs
2020-01-31T05:45:55.246650697Z ASP .NETCore Version: 3.1.0
2020-01-31T05:45:55.246654897Z Note: Any data outside '/home' is not persisted
2020-01-31T05:45:55.345854631Z Running oryx -appPath /home/site/wwwroot -output /opt/startup/startup.sh -defaultAppFilePath /defaulthome/hostingstart/hostingstart.dll -bindPort 8080 -userStartupCommand ''
2020-01-31T05:45:55.357795560Z Oryx Version: 0.2.20191105.2, Commit: 67e159d71419415435cb5d10c05a0f0758ee8809, ReleaseTagName: 20191105.2
2020-01-31T05:45:55.364315940Z Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml'
2020-01-31T05:45:55.364484245Z Could not find operation ID in manifest. Generating an operation id...
2020-01-31T05:45:55.364692150Z Build Operation ID: 16a4fd9c-cc6c-4d07-9412-245a90b8ae11
2020-01-31T05:45:56.217535655Z Writing output script to '/opt/startup/startup.sh'
2020-01-31T05:45:56.555709475Z Trying to find the startup DLL name...
2020-01-31T05:45:56.556273790Z Found the startup D name: JaykeBirdWebsite.dll
2020-01-31T05:45:56.556285190Z Running the command: dotnet "JaykeBirdWebsite.dll"
2020-01-31T05:45:57.764309083Z SETTING UP SQL SERVER
2020-01-31T05:45:57.765831625Z SUCCESS, PRODUCTION SERVER
2020-01-31T05:45:57.920253281Z Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Razor.Runtime, Version=3.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
2020-01-31T05:45:57.920277782Z
2020-01-31T05:45:57.920283082Z File name: 'Microsoft.AspNetCore.Razor.Runtime, Version=3.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
2020-01-31T05:45:57.920287482Z at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
2020-01-31T05:45:57.920292082Z at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
2020-01-31T05:45:57.920296782Z at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(MetadataToken caCtorToken, MetadataImport& scope, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1& derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
2020-01-31T05:45:57.920322383Z at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
2020-01-31T05:45:57.920327283Z at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType)
2020-01-31T05:45:57.920331383Z at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
2020-01-31T05:45:57.920335383Z at System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit)
2020-01-31T05:45:57.920339284Z at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit)
2020-01-31T05:45:57.920343284Z at System.Attribute.GetCustomAttribute(Assembly element, Type attributeType, Boolean inherit)
2020-01-31T05:45:57.920347284Z at System.Reflection.CustomAttributeExtensions.GetCustomAttribute[T](Assembly element)
2020-01-31T05:45:57.920351284Z at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartFactory.GetApplicationPartFactory(Assembly assembly)
2020-01-31T05:45:57.920366184Z at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateDefaultParts(String entryAssemblyName)
2020-01-31T05:45:57.920370284Z at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.GetApplicationPartManager(IServiceCollection services)
2020-01-31T05:45:57.920384785Z at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(IServiceCollection services)
2020-01-31T05:45:57.920388385Z at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddControllersCore(IServiceCollection services)
2020-01-31T05:45:57.920392085Z at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddControllersWithViewsCore(IServiceCollection services)
2020-01-31T05:45:57.920395885Z at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddControllersWithViews(IServiceCollection services)
2020-01-31T05:45:57.920399385Z at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddMvc(IServiceCollection services)
2020-01-31T05:45:57.920402985Z at Microsoft.AspNetCore.Identity.IdentityBuilderUIExtensions.AddRelatedParts(IdentityBuilder builder)
2020-01-31T05:45:57.920406685Z at Microsoft.AspNetCore.Identity.IdentityBuilderUIExtensions.AddDefaultUI(IdentityBuilder builder)
2020-01-31T05:45:57.920410786Z at Microsoft.Extensions.DependencyInjection.IdentityServiceCollectionUIExtensions.AddDefaultIdentity[TUser](IServiceCollection services, Action`1 configureOptions)
2020-01-31T05:45:57.920414486Z at JaykeBirdWebsite.Startup.ConfigureServices(IServiceCollection services) in D:\Documents\Visual Studio 2017\Projects\JaykeBirdWebsite\JaykeBirdWebsite\Startup.cs:line 47
2020-01-31T05:45:57.920418486Z at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
2020-01-31T05:45:57.920443786Z at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
2020-01-31T05:45:57.920447887Z at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services)
2020-01-31T05:45:57.920461987Z at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.g__Startup|0(IServiceCollection serviceCollection)
2020-01-31T05:45:57.920466287Z at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services)
2020-01-31T05:45:57.920469987Z at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.b__0(IServiceCollection services)
2020-01-31T05:45:57.920473787Z at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(Type startupType, HostBuilderContext context, IServiceCollection services)
2020-01-31T05:45:57.920477387Z at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass12_0.b__0(HostBuilderContext context, IServiceCollection services)
2020-01-31T05:45:57.920481287Z at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
2020-01-31T05:45:57.920484788Z at Microsoft.Extensions.Hosting.HostBuilder.Build()
2020-01-31T05:45:57.920488388Z at JaykeBirdWebsite.Program.Main(String[] args) in D:\Documents\Visual Studio 2017\Projects\JaykeBirdWebsite\JaykeBirdWebsite\Program.cs:line 16
2020-01-31T05:45:57.920492288Z
2020-01-31T05:45:57.930244057Z
2020-01-31T05:45:57.942703700Z ptrace(ATTACH, 29) FAILED Operation not permitted
2020-01-31T05:45:57.943221614Z Writing minidump with heap to file /home/logs/dumps/coredump.635e33bed9c7.29.1580449555
2020-01-31T05:45:58.359599189Z /opt/startup/startup.sh: line 12: 29 Aborted (core dumped) dotnet "JaykeBirdWebsite.dll"
-
SvenGlöckner 446 Reputation points
2020-02-11T10:22:58.713+00:00
4 additional answers
Sort by: Most helpful
-
Ronald Hempel 6 Reputation points Microsoft Employee
2020-01-31T08:48:18.743+00:00 You could do a self-contained deployment instead by following these steps: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/azure-apps/?view=aspnetcore-3.1&tabs=visual-studio#deploy-a-self-contained-preview-app
-
Frank Sebastià 1 Reputation point
2020-02-07T11:11:05.883+00:00 There's an open defect: See https://github.com/aspnet/Announcements/issues/401
See workaround there. -
Somnath Shukla 411 Reputation points
2020-02-07T11:25:16.627+00:00 Please go extensions
and add the 3.1.1 runtime -
SvenGlöckner 446 Reputation points
2020-02-10T13:52:09.943+00:00 Doesn't work for me. I installed 3.1.1 extension but still error.
Azure App Service output:
Application: w3wp.exe
CoreCLR Version: 4.700.19.56402
.NET Core Version: 3.1.0Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Razor.Runtime, Version=3.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
File name: 'Microsoft.AspNetCore.Razor.Runtime, Version=3.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'Even self-contained build does not work.