dotnet / dotnet/aspnetcore

HTTP Error 500.31 - ANCM Failed to Find Native Dependencies

Open
#34,588 8 comments 0 reactions 0 assignees View on GitHub
area-networking feature-iis investigate
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

Startup of a 3.1 app fails after the deployment to an Azure App service.

A bit more detailed log from the event logs:
```
Cannot use file stream for [D:\Windows\system32\SRM.deps.json]: No such file or directory

A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'D:\Windows\system32\'.

Failed to run as a self-contained app.

- The application was run as a self-contained app because 'D:\Windows\system32\SRM.runtimeconfig.json' was not found.

- If this should be a framework-dependent app, add the 'D:\Windows\system32\SRM.runtimeconfig.json' file and specify the appropriate framework.
```

#### Background
- a recently migrated ASP.NET core 2.1 app to 3.1. Running on Azure App service. Similar apps have been migrated in the same fashion, all without issue. One of the apps was deployed to the "problematic" app service but produced a working site. Other way around though doesn't work.
- framework dependent, `dotnet --list-runtimes` produces everything from 2.1.26 to 5.0.7, as far as I can see they are installed correctly, with `hostpolicy.dll` in them.
- InProcess hosting

#### SRM.runtimeconfig.json
```
{
"runtimeOptions": {
"tfm": "netcoreapp3.1",
"framework": {
"name": "Microsoft.AspNetCore.App",
"version": "3.1.0"
},
"configProperties": {
"System.GC.Server": true,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}
```

#### SRM.deps.json
```
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v3.1",
"signature": ""
},
"compilationOptions": {
"defines": [
"TRACE",
"RELEASE",
"NETCOREAPP",
"NETCOREAPP3_1"
],
"languageVersion": "8.0",
"platform": "",
"allowUnsafe": false,
"warningsAsErrors": false,
"optimize": true,
"keyFile": "",
"emitEntryPoint": true,
"xmlDoc": false,
"debugType": "portable"
},
"targets": {
".NETCoreApp,Version=v3.1": {
...
```
#### SRM.web.config
```








...
```
#### aspnetcore-debug
```
[aspnetcorev2.dll] Initializing logs for 'D:\Program Files\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll'. Process Id: 39152.. File Version: 13.1.19331.0. Description: IIS ASP.NET Core Module V2. Commit: 62eee6e6d21c95668a9e9529dce6562cc6c9f3bf.
[aspnetcorev2.dll] Resolving hostfxr parameters for application: 'dotnet' arguments: '.\SRM.dll' path: 'D:\home\site\wwwroot\'
[aspnetcorev2.dll] Known dotnet.exe location: ''
[aspnetcorev2.dll] Process path 'dotnet.exe' is dotnet, treating application as portable
[aspnetcorev2.dll] Resolving absolute path to dotnet.exe from 'dotnet.exe'
[aspnetcorev2.dll] Invoking where.exe to find dotnet.exe
[aspnetcorev2.dll] where.exe invocation returned: 'D:\Program Files (x86)\dotnet\dotnet.exe
D:\Program Files\dotnet\dotnet.exe
'
[aspnetcorev2.dll] Current process bitness type detected as isX64=1
[aspnetcorev2.dll] Processing entry 'D:\Program Files (x86)\dotnet\dotnet.exe'
[aspnetcorev2.dll] Binary type 0
[aspnetcorev2.dll] Processing entry 'D:\Program Files\dotnet\dotnet.exe'
[aspnetcorev2.dll] Binary type 6
[aspnetcorev2.dll] Found dotnet.exe via where.exe invocation at 'D:\Program Files\dotnet\dotnet.exe'
[aspnetcorev2.dll] Resolving absolute path to hostfxr.dll from 'D:\Program Files\dotnet\dotnet.exe'
[aspnetcorev2.dll] hostfxr.dll located at 'D:\Program Files\dotnet\host\fxr\5.0.7\hostfxr.dll'
[aspnetcorev2.dll] Treating '.\SRM.dll' as a single path argument
[aspnetcorev2.dll] Parsed hostfxr options: dotnet location: 'D:\Program Files\dotnet\dotnet.exe' hostfxr path: 'D:\Program Files\dotnet\host\fxr\5.0.7\hostfxr.dll' arguments:
[aspnetcorev2.dll] Argument[0] = 'D:\Program Files\dotnet\dotnet.exe'
[aspnetcorev2.dll] Argument[1] = '.\SRM.dll'
[aspnetcorev2.dll] Loading hostfxr from location D:\Program Files\dotnet\host\fxr\5.0.7\hostfxr.dll
[aspnetcorev2.dll] Event Log: 'Unable to locate application dependencies. Ensure that the versions of Microsoft.NetCore.App and Microsoft.AspNetCore.App targeted by the application are installed.'
End Event Log Message.
[aspnetcorev2.dll] Canceling standard stream pipe reader
[aspnetcorev2.dll] Failed HRESULT returned: 0x8000ffff at F:\workspace.1\_work\1\s\src\Servers\IIS\AspNetCoreModuleV2\AspNetCore\HandlerResolver.cpp:78
[aspnetcorev2.dll] Event Log: 'Could not find 'aspnetcorev2_inprocess.dll'. Exception message:
Cannot use file stream for [D:\Windows\system32\SRM.deps.json]: No such file or directory
A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'D:\Windows\system32\'.
Failed to run as a self-contained app.
- The application was run as a self-contained app because 'D:\Windows\system32\SRM.runtimeconfig.json' was not found.
- If this should be a framework-dependent app, add the 'D:\Windows\system32\SRM.runtimeconfig.json' file and specify the appropriate framework.
'
End Event Log Message.
[aspnetcorev2.dll] Failed HRESULT returned: 0x8000ffff at F:\workspace.1\_work\1\s\src\Servers\IIS\AspNetCoreModuleV2\AspNetCore\HandlerResolver.cpp:171
[aspnetcorev2.dll] Failed HRESULT returned: 0x8000ffff at F:\workspace.1\_work\1\s\src\Servers\IIS\AspNetCoreModuleV2\AspNetCore\applicationinfo.cpp:181
[aspnetcorev2.dll] Failed HRESULT returned: 0x8000ffff at F:\workspace.1\_work\1\s\src\Servers\IIS\AspNetCoreModuleV2\AspNetCore\applicationinfo.cpp:96
[aspnetcorev2.dll] Event Log: 'Failed to start application '/LM/W3SVC/621136035/ROOT', ErrorCode '0x8000ffff'.'
End Event Log Message.
```

Changing the deployment to a self-contained package seems to resolve the issue, but that's not really preferred.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.