HTTP Error 500.31 - ANCM Failed to Find Native Dependencies in IIS

限于喜欢 提交于 2020-04-10 07:50:46

问题


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.


回答1:


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



回答2:


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.




回答3:


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.




回答4:


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.




回答5:


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-->


来源:https://stackoverflow.com/questions/56630477/http-error-500-31-ancm-failed-to-find-native-dependencies-in-iis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!