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

2020-02-23 05:19发布

问题:

After upgrading my project to ASP.NET Core 2.2, I tried to run the application (locally of course) and the browser displayed an error message like in the below screenshot.

no more errors notified by visual studio error explorer. I don't know what's happen.

回答1:

In my case, I upgraded some nuget packages to net core 2.2, but I did not have the net core 2.2 sdk installed, so I went to net core website to download the latest sdk or runtime package, and then I did a net stop was /y and then a net start w3svc in the CMD as administrator. Problem solved for me.



回答2:

I ran into this issue and had a different solution. For me it was that I had a package that was out of date with the application (I had updated it on NuGet, and the library hadn't been replaced in production). Updating the package fixed it for me.

Note with this: I had to manually run dotnet.exe with the project dll in order to see the message that fixed it for me.

Hope this helps someone else down the road.



回答3:

I encountered this error after trying to publish from VS2017 to the production Windows 2016 server. (It worked fine in IIS Express on my local Win10 PC.)

I updated packages, all versions matching and updated in my code, .net core versions matching, restart IIS, rebooting... no joy.

In the Publish > Configure > Settings (left tab) I had to set the Target-runtime from "Portable" to "win-x64" (or whatever is relevant to your environment). I also opted to "Remove additional files at destination."

"Portable" is the default setting. I'm not sure what it takes for the "Portable" runtime to work properly, but might save someone else some time if a "Portable" runtime is not something you need.

Generally speaking, I get this error if something is mismatched in my environment. For example, one time I was upgrading one of my projects to .Net Core 3.1 from 2.2 and hadn't installed the ASP.NET Core Runtime Hosting Bundle on my server:

https://dotnet.microsoft.com/download/dotnet-core/3.1

Also, you can get this error if your Application Pool is set to True for Enable 32-Bit Applications. Try:

IIS Manager > Application Pools > app pool name > (right click) Advanced Settings > Enable 32-Bit Applications = False



回答4:

In my case it was the log level set incorrectly in the appsettings.json. Instead of Warning I've had Warn and this crashed the app with above error.



回答5:

you have 2 solution(this answer works on windows server I do not know anything about linux server).

first:

  • copy all folder(except bin and obj folder) of your project to server

  • open cmd in your project folder then run this command: dotnet run then all warning and error show to you(if you have error about above command not recognize download dot net core sdk from this link)

second:

  • you must changed hostingModel attribute from OutOfProcess to inprocess in web.config and you can change stdoutLogEnabled to true value for get your project error in logs folder
  • read your projects errors and fix those.

in my case web.config is:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\BMS.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess" />
    </system.webServer>
  </location>
</configuration>

and I change it to:

<?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=".\BMS.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>


回答6:

I ran into this issue today with my hosting - locally everything is ok but once I publish, I get this error.

I looked through the packages and found out that some .net core stuff was upgraded to 3.0 preview.

Then I changed the build option in VS2019 from "Framework-Dependent" to "Self-contained". It took 5 times longer to build and publish but now it works.

Now I'm checking with host tech support what might be an issue - officially they support 2.1 / 2.2 only, so this might be these packages from 3.0 Preview, however target build is 2.2.



回答7:

My issues was malformed appsetttings.json file. I enabled standard out logging via web.config and was able to get the underlying exception throwing this error.



回答8:

If resetting the project and manually copying Program and Startup classes worked for you, then something was clearly messed up. There are some bigger underlying problems with this. Using the OutOfProcess hosting model is okay, but with .Net Core 2.2 you should be able to use the InProcess hosting model, since it is naturally faster: everything is processed in IIS, without an extra HTTP-hop between IIS and your app's Kestrel server.

If you right-click your project file in the visual studio solution explorer, please make sure that AspNetCoreModuleName tag has AspNetCoreModuleV2 value (as opposed to the older AspNetCoreModule). Also, examine Windows Application Event Log to identify the potential culprit. Even though error messages there are somewhat cryptic, they might point you to the exact line number in the code that caused the failure.

Finally, in case you use CI/CD with TFS, there may be environment variable(s) in appsettings.json file that were not properly replaced with the actual values (URLs, etc.).



回答9:

For me the issue was caused by dotnet publish creating a web.config entry stdoutLogFile=".\logs\stdout". The correct value should be stdoutLogFile="\\?\%home%\LogFiles\stdout".

MSDN reference: https://blogs.msdn.microsoft.com/waws/2018/06/10/troubleshooting-http-502-5-startup-issues-in-azure-appservice-for-asp-net-core-websites/

This could be a bug in the ASP.NET Core 2.2.0 runtime which may have been fixed in a later version.



回答10:

My solution:

  • remove all projects with catalog
  • create new projects
  • copy all files but program.cs and startup.cs
  • manual copying from startup and program classes to new startup.cs and new program.cs

Works.



回答11:

This error started appearing on our Dev server. I had been using this publish command which creates a "self-contained" folder of files for deployment.

dotnet publish -c release -r win7-x64 --output:bin/self_contained

My fix was to instead publish a "framework-dependent" deployment using the following command:

dotnet publish --output:bin/framework_dependent

The dev server did have a few versions of .NET Core installed (2.2.3 and 2.2.5) in this folder *C:\Program Files\dotnet\shared

I am still not clear on why the self contained publish does not work. You might think the self contained publish would be the more reliable method, but in my case it was not.

This .NET Core blog post was helpful.



回答12:

I got this same error while deploying .Net core app which was targeting .Net framework on Windows server. I checked event viewer on the server and turns out server didn't have .net 4.7.2 installed.

Installing it resolved issue for me.



回答13:

Yet another scenario that caused this issue for me:

I am running the app pool identity with a service account and I had to run dotnet dev-certs https under this user to get rid of "System.InvalidOperationException: Unable to configure HTTPS endpoint." during startup.



回答14:

Looks like i had the same issue. It's happens because if you don't have global.json file in solution, then VS build(publish) .net core app with the last version that installed on your pc. So, i do the next solution:

add a global.json file with .net core version.

{
   "sdk": {
      "version": "2.2.402"
   }
}

From docs.microsoft.com:

global.json can be placed anywhere in the file hierarchy. The CLI searches upward from the project directory for the first global.json it finds. You control which projects a given global.json applies to by its place in the file system. The .NET CLI searches for a global.json file iteratively navigating the path upward from the current working directory. The first global.json file found specifies the version used. If that version is installed, that version is used. If the SDK specified in the global.json is not found, the .NET CLI rolls forward to the latest SDK installed. Roll-forward is the same as the default behavior, when no global.json file is found.

https://docs.microsoft.com/en-us/dotnet/core/versions/selection



回答15:

Be carefull publishing.

When i publish it to my PreProd envitoment this conf works well: Portable

But on my Prod enviroment that conf does not work. I had to choose the especificated one: win-x64

I dont know the reason about that. If someone know i'll gratefull to know!



回答16:

The problem occurs when I try to deploy the asp.net core (out-of-process hosting model) website to windows server 2012r2 IIS in production env. I fixed this with this solution:

Change application pool identity to administrator.



回答17:

Same failture happent on project publish. The issue ralated with the latest Microsoft.AspNetCore.App package. Just downcast it from from 2.2.x to 2.2.0 or goto dotnet.microsoft.com/download/dotnet-core/2.2 and get newest dotnet-hosting installer



回答18:

This happened to me when I deployed code using Entity Framework Core with migrations, and there was mismatch between the state of the database and the migrations in the code.



回答19:

I was also getting the same issue. And when I looked at the Output window of my solution.

Then I was able to see a different error, which is "The target process exited without raising CoreCLR started event", to fix this I had to remove the Microsoft.AspNetCore.All from my Nuget Packages and install Microsoft.AspNetCore.App. I also had to install the correct .Net SDK from here. Once this is done, restarted my machine and open the solution, the error was gone. Hope it helps



回答20:

This happened to me first time publishing an Azure Web App. Here is how I solved it:

Browse the site using Kudo/FTP. In the root folder there is a LogFiles folder where you find eventlog.xml. In this file I could see that my web app had an SqlException when Entity Framework Core was trying to setup the database, which lead me to check the database permissions (which was the problem for me).



回答21:

If you are working with ASP.Net Core version 2.2 then in appsettings.json just comment the line -

"AllowedHosts": "*"

it resolves the issue. My application working fine.