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.35k stars 9.99k forks source link

IIS dont Run my App in Asp.NetCore 2.2 Helpme Please #38298

Closed maximo03 closed 2 years ago

maximo03 commented 2 years ago

Hi, I have been investigating this problem for a long time, approximately 2 months and I cannot find a solution, I would appreciate any help My problem is that I have an application made in Asp.NetCore 2.2 and at the time of publishing it in IIS and when trying to access it in the browser, it throws me an error:

HTTP Error 500.30 - ANCM In-Process Start Failure

Common solutions to this issue: • The application failed to start • The application started but then stopped • The application started but threw an exception during startup

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


In the event viewer I have the following: evnt 1: Application: w3wp.exe CoreCLR Version: 4.6.28207.3 Description: The process was terminated due to an unhandled exception. Exception Info: exception code c0000005, exception address 00007FF8DABD57F5

event 2: Application '/LM/W3SVC/3/ROOT' with physical root 'C:\project\myapp\' hit unexpected managed exception, exception code = '0xe0434352'. Please check the stderr logs for more information.

event 3: Application '/LM/W3SVC/3/ROOT' with physical root 'C:\project\myapp\' failed to load clr and managed application. CLR worker thread exited prematurely

event 4: Faulting application name: w3wp.exe, version: 10.0.17763.1, time stamp: 0xcfdb13d8 Faulting module name: hostpolicy.dll, version: 2.2.28209.1, time stamp: 0x5d9de9d0 Exception code: 0xc0000005 Fault offset: 0x00000000000057f5 Faulting process id: 0x840 Faulting application start time: 0x01d7d71c0371a8fb Faulting application path: c:\windows\system32\inetsrv\w3wp.exe Faulting module path: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.2.8\hostpolicy.dll Report Id: 0cb273e2-131e-4a38-a973-dacc4070b06a Faulting package full name: Faulting package-relative application ID:

Fault bucket , type 0 Event Name: APPCRASH Response: Not available Cab Id: 0

Problem signature: P1: w3wp.exe P2: 10.0.17763.1 P3: cfdb13d8 P4: hostpolicy.dll P5: 2.2.28209.1 P6: 5d9de9d0 P7: c0000005 P8: 00000000000057f5 P9: P10:

Attached files: \?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER307F.tmp.dmp \?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER310C.tmp.WERInternalMetadata.xml \?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER312C.tmp.xml \?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER312A.tmp.csv \?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER313B.tmp.txt \?\C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_w3wp.exe_2c6f3b2dbb36969fad6694ae98a1cd24a52d0_98baeb8b_cab_22e031a7\memory.hdmp

These files may be available here: \?\C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_w3wp.exe_2c6f3b2dbb36969fad6694ae98a1cd24a52d0_98baeb8b_cab_22e031a7

Analysis symbol: Rechecking for solution: 0 Report Id: 0cb273e2-131e-4a38-a973-dacc4070b06a Report Status: 524388 Hashed bucket:

Fault bucket , type 0 Event Name: APPCRASH Response: Not available Cab Id: 0

Problem signature: P1: WindowsServerHostingBundle.exe P2: 3.1.19.21417 P3: 5ec2f717 P4: wixstdba.dll P5: 3.14.4118.0 P6: 5ec2f758 P7: c0000005 P8: 00003c80 P9: P10:

Attached files: \?\C:\ProgramData\Microsoft\Windows\WER\Temp\WER1F2D.tmp.WERInternalMetadata.xml

These files may be available here: \?\C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_WindowsServerHos_23f469a12e3e6b0e3542bc529a3bd12a1d2220_95626f3c_035b0992

Analysis symbol: Rechecking for solution: 0 Report Id: c55c272a-1098-48c7-a855-2aa5e9cb6d24 Report Status: 528484 Hashed bucket: Cab Guid: 0


And I cleared the server cache and rebooted many times, I uninstalled IIS and reinstalled it again, I gave IIS users permissions on the project directories, uninstalled .netRuntime 2.2 and tested with all versions from 2.2.0 to 2.2 .8 and it didn't work, he removed things from the web.config I also added it but in the end nothing of changing the word InProcess to OutProcess or deleting the V2 to the word AspNetcoreModuleV2 and other tests that I did and the STDOUT does not work either because it creates the.log file inside the log folder but it doesn't write anything to the file, I tried to migrate the app to 3.1 or version 5 but it doesn't work. And the weirdest thing of all is that if I run the project's .dll index in the console there if it works fine example "dotnet myapp.dll" then I still believe that it is an IIS error, it has problems with AspNetcoreModuleV2. Any more advice I can give IIS to fix this problem would be greatly appreciated. I am very frustrated and desperate.

Tratcher commented 2 years ago

Please check the stderr logs for more information.

What did the stderr logs show? See https://docs.microsoft.com/en-us/aspnet/core/test/troubleshoot-azure-iis?view=aspnetcore-6.0#aspnet-core-module-stdout-log-iis

edit oh, you tried that..

and the STDOUT does not work either because it creates the.log file inside the log folder but it doesn't write anything to the file

maximo03 commented 2 years ago

just wrote a log and this is what i got :

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive) at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase) at System.StartupHookProvider.CallStartupHook(String assemblyPath) at System.StartupHookProvider.ProcessStartupHooks()

blowdart commented 2 years ago

Please note that .NET 2.2 has been out of support for a long time and does not get security patches. From a security point of view you show update to a supported version as soon as possible.

maximo03 commented 2 years ago

Ancm.log

[aspnetcorev2.dll] Initializing logs for 'C:\Program Files\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll'. Process Id: 1180.. File Version: 13.1.21296.21. Description: IIS ASP.NET Core Module V2. Commit: 458d97420a173fe87487b58ec4aa47a4c9dc4710. [aspnetcorev2.dll] Resolving hostfxr parameters for application: 'dotnet' arguments: '.\myapp.dll' path: 'C:\project\myapp\' [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: 'C:\Program Files (x86)\dotnet\dotnet.exe C:\Program Files\dotnet\dotnet.exe ' [aspnetcorev2.dll] Current process bitness type detected as isX64=1 [aspnetcorev2.dll] Processing entry 'C:\Program Files (x86)\dotnet\dotnet.exe' [aspnetcorev2.dll] Binary type 0 [aspnetcorev2.dll] Processing entry 'C:\Program Files\dotnet\dotnet.exe' [aspnetcorev2.dll] Binary type 6 [aspnetcorev2.dll] Found dotnet.exe via where.exe invocation at 'C:\Program Files\dotnet\dotnet.exe' [aspnetcorev2.dll] Resolving absolute path to hostfxr.dll from 'C:\Program Files\dotnet\dotnet.exe' [aspnetcorev2.dll] hostfxr.dll located at 'C:\Program Files\dotnet\host\fxr\3.1.21\hostfxr.dll' [aspnetcorev2.dll] Converted argument '.\myapp.dll' to 'C:\project\myapp.\myapp.dll' [aspnetcorev2.dll] Parsed hostfxr options: dotnet location: 'C:\Program Files\dotnet\dotnet.exe' hostfxr path: 'C:\Program Files\dotnet\host\fxr\3.1.21\hostfxr.dll' arguments: [aspnetcorev2.dll] Argument[0] = 'C:\Program Files\dotnet\dotnet.exe' [aspnetcorev2.dll] Argument[1] = 'C:\project\myapp.\myapp.dll' [aspnetcorev2.dll] Loading hostfxr from location C:\Program Files\dotnet\host\fxr\3.1.21\hostfxr.dll [aspnetcorev2.dll] Canceling standard stream pipe reader [aspnetcorev2.dll] Loading request handler: 'C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\2.2.8\aspnetcorev2_inprocess.dll' [aspnetcorev2.dll] Creating handler application [aspnetcorev2_inprocess.dll] Initializing logs for 'C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\2.2.8\aspnetcorev2_inprocess.dll'. Process Id: 1180.. File Version: 12.2.19169.6. Description: IIS ASP.NET Core Module V2 Request Handler. Commit: e7f262e33108e92fc8805b925cc04b07d254118b. [aspnetcorev2_inprocess.dll] Waiting for initialization [aspnetcorev2_inprocess.dll] Starting in-process worker thread [aspnetcorev2_inprocess.dll] Resolving hostfxr parameters for application: 'dotnet' arguments: '.\myapp.dll' path: 'C:\project\myapp\' [aspnetcorev2_inprocess.dll] Known dotnet.exe location: 'C:\Program Files\dotnet\dotnet.exe' [aspnetcorev2_inprocess.dll] Process path 'dotnet.exe' is dotnet, treating application as portable [aspnetcorev2_inprocess.dll] Resolving absolute path to hostfxr.dll from 'C:\Program Files\dotnet\dotnet.exe' [aspnetcorev2_inprocess.dll] hostfxr.dll located at 'C:\Program Files\dotnet\host\fxr\3.1.21\hostfxr.dll' [aspnetcorev2_inprocess.dll] Converted argument '.\myapp.dll' to 'C:\project\myapp.\myapp.dll' [aspnetcorev2_inprocess.dll] Parsed hostfxr options: dotnet location: 'C:\Program Files\dotnet\dotnet.exe' hostfxr path: 'C:\Program Files\dotnet\host\fxr\3.1.21\hostfxr.dll' arguments: [aspnetcorev2_inprocess.dll] Argument[0] = 'C:\Program Files\dotnet\dotnet.exe' [aspnetcorev2_inprocess.dll] Argument[1] = 'C:\project\myapp.\myapp.dll' [aspnetcorev2_inprocess.dll] Initial Dll directory: '', current directory: 'c:\windows\system32\inetsrv' [aspnetcorev2_inprocess.dll] Setting dll directory to c:\windows\system32\inetsrv [aspnetcorev2_inprocess.dll] Setting current directory to C:\project\myapp\ [aspnetcorev2_inprocess.dll] Managed threw an exception -532462766 [aspnetcorev2_inprocess.dll] Starting shutdown sequence 1 [aspnetcorev2_inprocess.dll] Clr thread wait ended: clrThreadExited: 1 [aspnetcorev2_inprocess.dll] d:\b\w\da744fbcc13abce\src\servers\iis\aspnetcoremodulev2\commonlib\fileoutputmanager.cpp:142 Operation failed with LastError: 32 HR: 0x80070020 [aspnetcorev2_inprocess.dll] Event Log: 'Application '/LM/W3SVC/3/ROOT' with physical root 'C:\project\myapp\' hit unexpected managed exception, exception code = '0xe0434352'. Please check the stderr logs for more information.' End Event Log Message. [aspnetcorev2_inprocess.dll] Stopping in-process worker thread [aspnetcorev2_inprocess.dll] Stopping CLR [aspnetcorev2_inprocess.dll] Event Log: 'Application '/LM/W3SVC/3/ROOT' with physical root 'C:\project\myapp\' failed to load clr and managed application. CLR worker thread exited prematurely' End Event Log Message. [aspnetcorev2_inprocess.dll] Exception 'InvalidOperationException' caught at d:\b\w\da744fbcc13abce\src\servers\iis\aspnetcoremodulev2\inprocessrequesthandler\inprocessapplication.cpp:370 [aspnetcorev2_inprocess.dll] Failed HRESULT returned: 0x8007023e at d:\b\w\da744fbcc13abce\src\servers\iis\aspnetcoremodulev2\inprocessrequesthandler\dllmain.cpp:120 [aspnetcorev2_inprocess.dll] Starting app_offline monitoring in application 'C:\project\myapp\' [aspnetcorev2_inprocess.dll] Starting file watcher thread

Tratcher commented 2 years ago

There's no indication of an issue here with IIS, ANCM, or the runtime. It's more likely an issue with how you publish the app.

A) Can you get it working with a new, empty 3.1+ app? B) Does C:\project\myapp contain the published output for your app? What were the publish settings? Can you run dotnet myapp.dll from the command line in that directory?

maximo03 commented 2 years ago

Can you run from the command line in that directory?C:\project\myappdotnet myapp.dll?

Yessssss!

Can you get it working with a new, empty 3.1+ app?

IIS if it works for me with new and empty applications in 3.1 and 5 the problem is those of 2.2 until the new clean ones generated with visual studio does not execute them gives the same error 500.30 ANCM

maximo03 commented 2 years ago

the way of publish is a recommend by visual studio Configuration: Release Target framework: netcoreapp2.2 Mode of Implementation: dependent on the framework Target Runtime: Portable

It should be noted that I already tried the other options with independent implementation mode and target Runtime win-x86, win-x64, win-arm, and I tried another clean virtual server and only installed IIS and .NeCorRuntime 2.2.8 publish the site and if it worked, but in my production server it does not work despite having everything installed

Tratcher commented 2 years ago

2.2 is out of support and we can't invest resources debugging it. You need to use at least 3.1.

serfend commented 2 years ago

2.2 is out of support and we can't invest resources debugging it. You need to use at least 3.1.

i have a completly same problem (500.30 with almost samve logs and events) when i use .net5.0.12 on winserver2019-iis

adityamandaleeka commented 2 years ago

@serfend Can you file a new issue for your issue and provide the logs/events?

adityamandaleeka commented 2 years ago

@maximo03 Startup hooks are not supported with 2.2. You may want to check if the DOTNET_STARTUP_HOOKS environment variable is set, and unset it if so.

maximo03 commented 2 years ago

Since I spent a lot of time on this error, what I did was migrate the app to Net5 and it worked fine, I'm still testing it to see if all the features work well. Thank you very much for all your help.