57

I try to run a Blazor application.

Web.Server runs .NET Core 3.0
Web.Client runs .NET Standard 2.0
Web.Shared runs .NET Standard 2.0

After publishing and uploading the application to IIS i get this error:

HTTP Error 500.31 - ANCM Failed to Find Native Dependencies
Common solutions to this issue:
The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found.

Event Viewer contains this error message:

HTTP Error 500.31 - ANCM Failed to Find Native Dependencies

When I run dotnet --info I can see that I both Microsoft.NetCore.App and Microsoft.AspNetCore.App contains version 3: PS C:\Users\FooBar> dotnet --info .NET Core SDK (reflecting any global.json): Version: 3.0.100-preview6-012264 Commit: be3f0c1a03

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100-preview6-012264\

Host (useful for support):
  Version: 3.0.0-preview6-27804-01
  Commit:  fdf81c6faf

.NET Core SDKs installed:
  1.0.4 [C:\Program Files\dotnet\sdk]
  2.0.0 [C:\Program Files\dotnet\sdk]
  2.1.101 [C:\Program Files\dotnet\sdk]
  3.0.100-preview6-012264 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview6.19307.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview6-27804-01 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview6-27804-01 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download

ASP.NET Core Diagnostics:

IMPORTANT: This report might contain confidential information. Mask such before sharing to others.
-----
System Time: 6/18/2019 12:50:58 AM
Processor Architecture: AMD64
OS: Microsoft Windows NT 10.0.17763.0
Server Type: IIS

Scan 31 installed module(s).
ASP.NET Core module version 2 is installed for .NET Core 2.2 and above: C:\Program Files\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll (13.0.19158.0).

Scan 86 registered handler(s).
* Found a valid ASP.NET Core handler as { Name: aspNetCore, Path: *, State: Enabled, Module: AspNetCoreModuleV2, Entry Type: Local }.
  Visual C++ runtime is detected (expected: 14.0, detected: 14.14.26405.0 built by: VCTOOLSREL): C:\WINDOWS\system32\msvcp140.dll.
Scan aspNetCore section.
    "processPath": dotnet.
    "arguments": .\Web.Server.dll.
    "hostingModel": inprocess.
"runtimeTarget": .NETCoreApp,Version=v3.0.
Please refer to pages such as https://dotnet.microsoft.com/download/dotnet-core/2.2 to verify that ASP.NET Core version 13.0.19158.0 matches the runtime of the web app.

Why is IIS throwing this error on my server?

Note: It works from Visual Studio 2019.

Westerlund.io
  • 2,743
  • 5
  • 30
  • 37
  • Can you run a report to reveal more information about your IIS setup? https://docs.jexusmanager.com/tutorials/ancm-diagnostics.html – Lex Li Jun 17 '19 at 13:44
  • @LexLi I just generated a report through ASP.NET Core Diagnostics but I can't seem to figure out from the report what is throwing this error. – Westerlund.io Jun 18 '19 at 07:53
  • 1
    No obvious issue is identified by the report. As 3.0 documentation is sparse at this moment, you probably need to debug the code yourself, https://github.com/aspnet/AspNetCore/tree/release/3.0-preview6/src/Servers/IIS – Lex Li Jun 18 '19 at 17:09
  • Do you find a solution? If yes, share please. – Diego Venâncio Jun 20 '20 at 21:04

17 Answers17

21

I have received the same error after upgrading my ASP.NET Core project from .NET Core 3.0 to 3.1 and installing Microsoft .NET Core 3.1.0 - Windows Server Hosting.

Quick (but bad) fix

changed the web.config handler from AspNetCoreModuleV2 to AspNetCoreModule and it worked ok.

Good fix

Find the underlying cause by inspecting Event Viewer. There might be multiple causes for this error, but in my case it was not finding an assembly related to CodeAnalysis

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

Could not find 'aspnetcorev2_inprocess.dll'. Exception message: Error: An assembly specified in the application dependencies manifest (myproject.deps.json) was not found: package: 'Microsoft.CodeAnalysis.CSharp.Workspaces', version: '3.3.1' path: 'lib/netstandard2.0/Microsoft.CodeAnalysis.CSharp.Workspaces.dll'

Although they are related these messages were in different events.

Community
  • 1
  • 1
Alexei - check Codidact
  • 22,016
  • 16
  • 145
  • 164
  • 8
    FWIW: I ran into [a similar issue](https://stackoverflow.com/questions/60839745/troubleshooting-500-31-ancm-on-azure-app-service/60839746), but on Azure App Services where I don't have access to the Windows Event Viewer. Given that, I posted a quick summary of [how to troubleshoot these issues on Azure App Services](https://stackoverflow.com/a/60839746/3025856). I figured I'd leave a reference here for anyone in a similar situation. – Jeremy Caney Mar 24 '20 at 22:10
  • 2
    The same issue, change to AspNetCoreModule it WORKS. After that change to AspNetCoreModule V2 and it still WORKS. Really strange. – andrewwang1TW May 04 '20 at 01:54
  • found the cause then how to solve? – Abdulhakim Zeinu Nov 06 '21 at 04:49
21

I just updated from NET5 - NET6 and thought I'd installed the hosting bundle before getting this error.

enter image description here

You need to actually click the Hosting Bundle link and not the x64 / x86 next to it.

That one file should be all you need. I had installed the x64 runtime only.

Simon_Weaver
  • 140,023
  • 84
  • 646
  • 689
13

I have the same issue. In my case the problem was in the wrong RID in dotnet publish command. I was doing a self-contained deployment and then downloaded it to app service.

As a result, the command should be like this:

dotnet publish -c Debug -r win-x86 --self-contained
Igorgy
  • 174
  • 10
10

Below solution is working fine.

To solve this issue without reinstalling iis:

  • In web.config change AspNetCoreModuleV2 to AspNetCoreModule. And restart app and pool. Then stop app and pool. And replace to back. Run app and pool.
h3t1
  • 1,126
  • 2
  • 18
  • 29
user13822690
  • 101
  • 1
  • 2
  • This really doesn't seem right - see https://stackoverflow.com/questions/66594260/what-is-the-difference-between-aspnetcoremodule-and-aspnetcoremodulev2 - Can anyone explain how this is working (and this answer has no downvotes so it seems to be). – Simon_Weaver Dec 03 '21 at 23:22
9

In case this helps others, when migrating from .net core 3.1 to .Net 5.

  1. Install the sdk from here.
  2. Update all projects and web in solution to <TargetFramework>net5.0</TargetFramework>.
  3. Update nuget packages.

This all worked fine locally, however, when I pushed the changes to Azure DevOps, all everything run in the pipeline as normal, the web application was giving the same error as the OP.

I solved my issue by going into the Azure Portal:

  1. Navigate to the App Service blade
  2. Under Settings, go to Configuration
  3. General Settings tab and set the Stack to .NET Core.

enter image description here

Christian Phillips
  • 18,399
  • 8
  • 53
  • 82
8

There might be many reasons for this error. To find exact error, Change "stdoutLogEnabled" to true in web.config. This will generate logfile where you can find exact problem. In my case, I had missed few dlls.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\MyWebsite.Web.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>
<!--ProjectGuid: 20E974DC-FA0B-4957-8D1E-3466E348F82E-->
prisan
  • 1,251
  • 12
  • 9
4

Addition to the answer from @Alexei:

I got this error using a Azure App Service.

Goto https://<your-app>.scm.azurewebsites.net/detectors?type=tools&name=eventviewer or log in to the Azure portal and navigate to "Diagnose and solve problems" to see a better error description.

enter image description here

In my case I had the error:

Could not find 'aspnetcorev2_inprocess.dll'. Exception message: Failed to add 'D:\local\UserProfile.dotnet\tools' to the PATH environment variable. Add this directory to your PATH to use tools installed with 'dotnet tool install'.

I did not recognize aspnetcorev2_inprocess.dll so I decided to check my wwwroot folder to look for clues:

https://<your-app>.scm.azurewebsites.net/DebugConsole/?shell=powershell

Located at D:\home\site\wwwroot in my case. Here I could see a couple of DLLs I did not expect to be there. Turned out that our Azure DevOps Pipeline published our solution instead of web project and we had merged a new Azure Functions project to develop branch. After fixing the publish everything worked.

Useful link for more troubleshooting:

https://learn.microsoft.com/en-us/aspnet/core/test/troubleshoot-azure-iis?view=aspnetcore-3.1

Ogglas
  • 62,132
  • 37
  • 328
  • 418
2

Found this post while having the same issue trying to run a Dot net core 3.1 WebApp on a IIS. Installing these helped me: enter image description here

Andreas
  • 775
  • 2
  • 11
  • 20
1

Just adding what happens to me - maybe it helps someone else.

I had migrated from 2.* to 3.1.5, but I did not remove two old nuget packages.

When I got rid of them, I deployed it again and it worked.

(To be more precise, I removed one of them and updated the other one - the Microsoft.EntityFrameworkCore.SqlServer whas 3.1.4 instead of 3.1.5)

heringer
  • 2,698
  • 1
  • 20
  • 33
0

I had the same error message when I deployed from our dev server to our staging server. I fixed the issue by adding the Nuget package Microsoft.NetCore.App (version 2.2.8). Sometimes the answer is in the error message.

CodeCaptain
  • 379
  • 4
  • 10
  • 2
    Given that this thread is specifically about .NET Core 3.0, and there isn't a `Microsoft.NetCore.App` (or `Microsoft.AspNetCore.App`) NuGet metapackage for .NET Core 3.0, this doesn't provide an answer to this question—though it may well be useful for users looking for a solution to this problem on .NET Core 2.x. – Jeremy Caney Mar 20 '20 at 00:47
0

I had same issue that listed the name of missing package on my workstation. Open command prompt and run below to see what all packages are available on your machine.

dotnet --info

It will list all .Net core sdks & runtime installed.Then you will find weather required packages are missing or not. You can install those required packages from official site https://dotnet.microsoft.com/download/dotnet-core .Rebuilt your solution and it should work.

Omkar Manjare
  • 53
  • 1
  • 5
0

To solve this issue without reinstalling iis I found some solution. Hope it help someone. In web.config change AspNetCoreModuleV2 to AspNetCoreModule. And restart app and pool. Then stop app and pool. And replace to back. Run app and pool.

Juriy Sh
  • 27
  • 2
0

Got same error, also after publishing.

dotnet --info showed Microsoft.AspNetCore.App had the version in question, but not Microsoft.NetCore.App.

I was behind one VS update, so I ran that and it fixed it.

Don't know for sure, but wonder if Microsoft.AspNetCore.App was upgraded to publish, and Microsoft.NetCore.App wasn't.

John MacIntyre
  • 12,910
  • 13
  • 67
  • 106
0

I was using IISExpress server in Visual Studio when this error came up. It also told me that it was something to do with Microsoft.Azure.DocumentDB.Core.dll. In my .NET class library project, I had a hard reference of this DLL in place of referring to it via nuget package. I had done this as I was referring to this DLL from a .NET Framework v4.6 project. For me below steps worked to resolve this issue:

  • Clean solution
  • Rebuild solution
RBT
  • 24,161
  • 21
  • 159
  • 240
0

I had this error publishing to an Azure AppService today. In my case, a previous site already existed in the AppService and when I published the new site into it I got the 500.31 error. In my case, I updated the publish profile to delete the existing files on the site first, re-published and that fixed the issue (I assume there was something hanging out there in conflict).

b.pell
  • 3,873
  • 2
  • 28
  • 39
0

I had the same error. Make sure the arguments in your web.config reference your startup project name:

enter image description here

ping
  • 663
  • 6
  • 13
0

In my case I have 2 projects in my solution:

  • Azure Functions
  • Web App

In Azure Functions I'm referencing something from WebApp ( a DTO). Locally everything works but when deployed to Azure get this error and worst of all NO exception message. Why does the fact that Azure Functions (which are deployed completely separately) dependency on Web App breaks Web App's deployment and causes this error is beyond me.

ihor.eth
  • 2,207
  • 20
  • 27