IIS hosting error: HTTP Error 502.5 - ANCM Out-Of-Process Startup Failure

I would really appreciate it if someone could assist with this please.

I am attempting to run PowerShell Universal under IIS in Windows 2016. All OS updates applied and I am running with the latest version of PowerShell Universal.

Steps to install:

  1. Installed the MSI firstly.
  2. Disabled the service.
  3. Downloaded the ZIP and placed it’s contents into c:\inetpub\wwwroot\PowerShellUniversal
  4. Created an application pool. Used the standard config as documented here: IIS Windows Auth - PowerShell Universal (ironmansoftware.com) I also checked the video here as well: Hosting PowerShell Universal in IIS - YouTube
  5. Changed the web.config however Integrated Windows authentication is set to false.
  6. Changed the Arguments string to point at the relative and absolute path of the Universal.Server.dll.
  7. Made sure the service user has full access to the inetpub\wwwroot\PowerShellUniversal directory. (Not something I want to leave). Also made sure this user has full access to the UniversalAutomation and PowerShellUniversal directories under c:\programdata
  8. Unblocked the DLL’s that were extracted with the Zip file.
  9. Service user is now running as local admin. Again, I won’t want to leave it like this.
  10. Gave permission to start services to the service account.
  11. I have attempted to install .net core 2.1, 2.2 and 3.1. Installation has been successfull and I can see it in the available modules for the website. I also have .net 5 preview installed for something else I will be working on in a week or two.

The application pool has 32 bit compatibility disabled, Load User Profile is set to true and it is running using a specifically created service account.

The error I encounter is:

HTTP Error 502.5 - ANCM Out-Of-Process Startup Failure

Common solutions to this issue:

  • The application process failed to start
  • The application process started but then stopped
  • The application process started but failed to listen on the configured port

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

Warning in the event log under Application is:

Application ‘/LM/W3SVC/2/ROOT’ with physical root ‘C:\inetpub\wwwroot\PowerShellUniversal’ failed to start process with commandline 'C:\inetpub\wwwroot\PowerShellUniversal\Universal.Server.exe ’ at stage ‘PostStartCheck’, ErrorCode = ‘0x8027025b’, assigned port 42512, retryCounter ‘0’.

Error in the event log is:
Faulting application name: Universal.Server.exe, version: 1.0.0.0, time stamp: 0x5dcec899
Faulting module name: KERNELBASE.dll, version: 10.0.14393.3986, time stamp: 0x5f77fd5b
Exception code: 0xe0434352
Fault offset: 0x0000000000034f38
Faulting process id: 0x1dc8
Faulting application start time: 0x01d6ae30bd9690a3
Faulting application path: C:\inetpub\wwwroot\PowerShellUniversal\Universal.Server.exe
Faulting module path: C:\Windows\System32\KERNELBASE.dll
Report Id: 60f733a5-11a7-4ac7-9f0e-a72029aa48bd
Faulting package full name:
Faulting package-relative application ID:

Another error:

Application: Universal.Server.exe
CoreCLR Version: 4.700.19.56402
.NET Core Version: 3.1.0
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ComponentModel.Win32Exception (2): The system cannot find the file specified.
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at UniversalAutomation.JobProcessManager.StartProcessAsCurrentUser(String powerShellPath, String commandLine, Variable credential) in D:\a\universal\universal\src\Universal.Server\Services\JobProcessManager.cs:line 202
at UniversalAutomation.JobProcessManager.StartApiProxy(Int32 port, ExecutionEnvironment environment) in D:\a\universal\universal\src\Universal.Server\Services\JobProcessManager.cs:line 223
at Universal.Server.Services.ApiProxy.Start() in D:\a\universal\universal\src\Universal.Server\Services\ApiProxy.cs:line 91
at UniversalAutomation.StartupService.StartAsync(CancellationToken cancellationToken) in D:\a\universal\universal\src\Universal.Server\Services\StartupService.cs:line 67
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
at Universal.Server.Program.Main(String[] args) in D:\a\universal\universal\src\Universal.Server\Program.cs:line 30

Current web.config:

<?xml version="1.0" encoding="utf-8"?>

Error in log found in c:\programdata\PowerShellUniversal

2020-10-29T17:58:12.6554885+00:00 0HM3S5M75SQ12:00000001 [INF] Request starting HTTP/1.1 POST http://127.0.0.1:41783/iisintegration 0 (ca22a1cb)
2020-10-29T17:58:12.6556845+00:00 0HM3S5M75SQ12:00000001 [INF] Request finished in 0.2409ms 202 (791a596a)
2020-10-29T17:58:12.6605135+00:00 [INF] Application is shutting down… (90f52c38)
2020-10-29T17:58:13.2264444+00:00 [WRN] Exception during stop. (69827b32)
System.NullReferenceException: Object reference not set to an instance of an object.
at Universal.Server.Services.SecurityProxy.StopAsync() in D:\a\universal\universal\src\Universal.Server\Services\SecurityProxy.cs:line 83

Sorry that this post is so long. I am hoping to illustrate that I have gone as far as I can with this prior to asking for assistance.

Your web.config should look something like below. Refer to the following for step by step:
https://docs.ironmansoftware.com/config/hosting-iis#step-4-iis-web-site-configuration

Also, you had stated in point number 6. that you pointed to the relative path of Universal.Server.dll . I believe this is incorrect in the documentation and should point to the Universal.Server.exe (as in my example below).

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="C:\inetpub\wwwroot\powershellUniversal\Universal.Server.exe" arguments="" stdoutLogEnabled="true" stdoutLogFile=".\logs\log" hostingModel="InProcess" forwardWindowsAuthToken="false"/>
  </system.webServer>
</configuration>
<!--ProjectGuid: 588ACF2E-9AE5-4DF1-BC42-BCE16A4C4EDE-->

Thanks. Very appreciated. I made the change on a test server and that worked.

On the live, I’m running it as a service for the moment.

Thanks again for getting back to me.