IIS AspNetCore Module V2 throws failed to load coreclr

See original GitHub issue

We upgraded our asp.net core site from .NET Core 2.2 --> 3.1

The site works fine for about 18 hours and then crashes. Restarting it gives us:

HTTP Error 500.37 - ANCM Failed to Start Within Startup Time Limit

Looking in the event log, we see this:

3/4/2020 2:31:54 AM
Source: WAS
EventId: 5009
A process serving application pool 'SSO' terminated unexpectedly. The process id was '11960'. The process exit code was '0xc0000409'.
3/4/2020 2:33:51 AM
Source: WAS
EventId: 5010
A process serving application pool 'SSO' failed to respond to a ping. The process id was '13988'.
3/4/2020 2:35:52 AM
EventId: 1007
Source: IIS AspNetCore Module V2
Application '/LM/W3SVC/28/ROOT' with physical root 'D:\Sites\SSO\Site-Prod\' failed to load coreclr. Exception message:
Managed server didn't initialize after 120000 ms.

No amount of recycling / rebooting or redeploying gets the site back up and running.

Deploying the old 2.2 code works immediately.

Any idea what might be causing this?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:21 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
davidfowlcommented, Mar 18, 2020

Putting this in the issue since I looked at the dump.

After looking at your code I think I’ve figured out the issue. You have calls to BuildServiceProvider throughout your startup code some in per request locations. That will create a new service provider universe and you’re also not disposing things.

Some examples on how to fix things:

services.AddSingleton<SsoClient>((provider) => {
                var svcProvider = services.BuildServiceProvider(); 
                var factory = svcProvider.GetService<ILoggerFactory>();
                var logger = factory.CreateLogger<SsoClient>(); 
                return new SsoClient(salesforceApiSettings.RestBaseUrl,
                    salesforceApiSettings.Username,
                    salesforceApiSettings.Password,
                    salesforceApiSettings.ApiKey,
                    salesforceApiSettings.ClientSecret,
                    salesforceApiSettings.ClientId,
                    logger);
            });

Should be:

services.AddSingleton<SsoClient>((provider) => {
                var factory = provider.GetService<ILoggerFactory>();
                var logger = factory.CreateLogger<SsoClient>(); 
                return new SsoClient(salesforceApiSettings.RestBaseUrl,
                    salesforceApiSettings.Username,
                    salesforceApiSettings.Password,
                    salesforceApiSettings.ApiKey,
                    salesforceApiSettings.ClientSecret,
                    salesforceApiSettings.ClientId,
                    logger);
            });

The real issue is in OnMessageReceived in the call to AddOpenIdConnect, you build the service provider potentially twice per request.

var sp = services.BuildServiceProvider();
var interactSvc = sp.GetService<IIdentityServerInteractionService>();

Should be:

var interactSvc = m.HttpContext.RequestServices.GetService<IIdentityServerInteractionService>();
1reaction
akiandercommented, Mar 12, 2020

I’ll work on getting a runnable sample I can upload - it might be a few days given my current workload. Just have to carve out the portions of the site that are confidential.

Read more comments on GitHub >

github_iconTop Results From Across the Web

iis 8 - .NET Core 3.0 and IIS: HTTP Error 500.30 - ANCM In ...
I changed the specification in Web.config to run out of process. Originally the specification was for InProcess as follows: <aspNetCore ...
Read more >
IIS AspNetCore Module V2: Failed to start application '/LM/ ...
Common solutions to this issue: The specified version of Microsoft.NetCore.App or Microsoft.AspNetCore.App was not found. Troubleshooting steps:
Read more >
HTTP Error 500.30 - ASP.NET Core app failed to start
NET Core CLR in-process, but it fails to start, thus preventing the app from running. Unfortunately, the cause of a process startup failure...
Read more >
HTTP Error 500.30 - ASP.NET Core app failed to Start
Its not opening and it shows HTTP Error 500.30 - ASP. ... physical root 'C:\Program Files (x86)\UiPath\TestManager' failed to load coreclr.
Read more >
ASP.NET Core IIS InProcess Hosting Issue in .NET Core 3.1
The ASP.NET Core Module attempts to start the .NET Core CLR in-process, but it fails to start. The cause of a process startup...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found