Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP Error 500.31 - Failed to load ASP.NET Core runtime

I'm having issues deploying .NET Core applications to IIS on a Windows 10 machine.

When I deploy to IIS and navigate to the site I recieve the message:

"HTTP Error 500.31 - Failed to load ASP.NET Core runtime
Common solutions to this issue:
The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.
Troubleshooting steps:
Check the system event log for error messages
Enable logging the application process' stdout messages
Attach a debugger to the application process and inspect
For more information visit: https://go.microsoft.com/fwlink/?LinkID=2028526

In my event viewer, every call to the page generates 3 error messages.

  1. Unable to locate application dependencies. Ensure that the versions of Microsoft.NetCore.App and Microsoft.AspNetCore.App targeted by the application are installed.

  2. Could not find 'aspnetcorev2_inprocess.dll'. Exception message:

  3. Failed to start application '/LM/W3SVC/4/ROOT', ErrorCode '0x8000ffff'.

On these alone, I'd go down the rabbit hole of thinking there's some issue in the build of the project or perhaps my installation of some .NET Core package except:

  1. I have two other .NET Core 3.1 sites running at different ports. In fact, if I copy the files from the directory of a working site, to the directory of a non-working site they will not run through IIS. If I copy files from the directory of a non-working site, to a working site, those files will run through IIS.
  2. If I click on the executable for any of the sites and navigate to the specified localhost, they open up in a web browser just fine.
  3. I can run all manner of framework-dependent and Self-Contained .Net Core 3.1 and .Net Core 5.0 console apps anywhere on the same system.
  4. The two sites that do work, showed the same error message the first time I went to publish. I tried adjusting settings, reinstalling runtimes and the like but failed to isolate anything that caused them to start running a few hours after the first attempt at deployment.
  5. There is no visibile difference in settings in the Application Pool or the sites themselves between the sites that work and the sites that don't.

I think there must be some issue with how I've configured IIS, the sites, or the application pools, but as best I can tell there isn't any difference. If anyone has encountered this, I'm all ears for suggestions.

like image 293
Vinnie Fusca Avatar asked Dec 16 '20 05:12

Vinnie Fusca


People also ask

What is HTTP Error 500.31 failed to load ASP NET core runtime?

'HTTP Error 500.31 - Failed to load ASP.NET Core runtime' Error when Opening Xtraction. This is because the . NET Core 5. x runtime is not installed.

How do I know if NET Core runtime is installed?

You can see both the SDK versions and runtime versions with the command dotnet --info .

How do I fix the specified version of Microsoft NET Core app or Microsoft Aspnetcore app was not found?

Updating the extension to the current latest version that is v 6.0. 2 fixed the issue.


2 Answers

In my case, the target machine was missing the ASP.NET Core runtime itself.

Issue is resolved after installing the Hosting Bundle from .Net Core 3.1

like image 98
Alex Monkey Avatar answered Sep 17 '22 13:09

Alex Monkey


I was getting the same error messages for a new .NET Core 3.1 framework-dependent web app on an IIS server which was already hosting other .NET Core 3.1 framework-dependent web apps with no problem. The messages in Event Viewer were slightly different; but also very hard to find - sometimes I couldn't see any events which seemed to relate.

If I converted the site to stand-alone "win-x86", it worked; but stand-alone "win-x64" didn't work.

After days of...

  • Reading the information on the linked Microsoft URL in the error message,
  • running the site from the command line (no problem),
  • checking dotnet --info on the IIS server,
  • checking dotnet --info on the build server,
  • staring at JSON config files, project files, build settings, publish settings and IIS settings

...this turned out to be an AppPool setting.

In the AppPool's Advanced Settings, there is an "Enable 32-Bit Applications" setting, which IIS considers the default to be False; but on mine was True. Toggling this setting caused the site to work and fail, when False and True, respectively.

It had been set to True on my site because we use octopusdeploy to deploy our site, and the "IIS AppPool – Create" step has an option relating to this setting; but in Octopus, the default value is True, so this needed turning off.

like image 22
Richardissimo Avatar answered Sep 20 '22 13:09

Richardissimo