dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.57k stars 10.05k forks source link

HTTP Error 502.5 - ANCM Out-Of-Process Startup Failure (when using a third party library) #9248

Closed max-favilli closed 5 years ago

max-favilli commented 5 years ago

Describe the bug

Our application works fine in development with IIS Express but when deployed on IIS running on Windows Server 2012 R2 we get: HTTP Error 502.5 - ANCM Out-Of-Process Startup Failure

In our opinion this is the direct outcome of adding a dependency to a third party dll library (Unicredit payment gateway)

Both development machines and target server were already updated to netcore2.2.

Event log has two entries:

Application '/LM/W3SVC/15/ROOT' with physical root 'C:\websites\mcgomme.com\' failed to start process with commandline 'C:\websites\mcgomme.com\maduka.exe ' with multiple retries. The last try of listening port is '12217'. See previous warnings for details. Application '/LM/W3SVC/15/ROOT' with physical root 'C:\websites\mcgomme.com\' failed to start process with commandline 'C:\websites\mcgomme.com\maduka.exe ' at stage 'PostStartCheck', ErrorCode = '0x8027025b', assigned port 12217, retryCounter '0'.

stdoutlog is empty aspnetcore-debug.log has the following:

[aspnetcorev2_outofprocess.dll] Failed HRESULT returned: 0x8027025b at c:\b\w\da744fbcc13abce\src\servers\iis\aspnetcoremodulev2\outofprocessrequesthandler\processmanager.cpp:167 [aspnetcorev2_outofprocess.dll] Failed HRESULT returned: 0x8027025b at c:\b\w\da744fbcc13abce\src\servers\iis\aspnetcoremodulev2\outofprocessrequesthandler\forwardinghandler.cpp:138 [aspnetcorev2_outofprocess.dll] FORWARDING_HANDLER::~FORWARDING_HANDLER

These logs and errors are not very useful in understanding what's going on. If we remove the third party dll library and comment the code using it and deploy the application works.

But I don't know how to blame the library since it works in development using IIS Express and I can't see any meaningful error in the logs explaining what is wrong with it.

I am aware of https://github.com/aspnet/AspNetCore/issues/9151 and https://github.com/aspnet/AspNetCore/issues/6111 none of the proposed solutions there worked, and our problem seems more specific and related to the use of a third party library.

max-favilli commented 5 years ago

I can't attach the dll but I can send it privately if it's useful.

Any suggestion on how to get something meaningful about what's wrong through logs or something?

Thanks in advance for any help.

analogrelay commented 5 years ago

Can you try using the in-proc mode for IIS? There are some initialization issues in out-of-proc that are easier to observe/diagnose in in-proc.

analogrelay commented 5 years ago

Closing this as we haven't heard from you and generally close issues with no response after ~7 days. Please feel free to comment if you're able to get the information we're looking for and we can reopen the issue to investigate further!

yeyener commented 5 years ago

In case you are checking only the errors in event logs, I'd recommend to look at the previous warnings too. I found out that my connection string was in a bad format by checking the warnings

kiwiant commented 5 years ago

I suspect we have a similar issue after switching the InProcess and using DFS to replicate the site files between servers and can be reproduced as follows:

  1. Deploy to server A.
  2. DFS replicates the changes in almost real time to Server B.

Server A spins up the site whereas Server B results in "ANCM In-Process Handler Load Failure". My theory is that one or more library files haven't quite replicated when the ANCM spins up the site but never appears to retry on subsequent requests.

Perhaps issues #9912 and #6111 are related?

DanielRBowen commented 5 years ago

I have a project with a 32 bit com object which I reference in a background/service web api project and when I set the project to x86 instead of any cpu then I get HTTP Error 500.0 - ANCM In-Process Handler Load Failure