New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IIS AspNetCore Module V2 throws failed to load coreclr #19555
Comments
Generally this occurs because either: Your application is taking longer than 120 seconds to start up and be able to process the first request, or your application is crashing. Can you post a runnable sample that reproduces the problem or detail exactly what your startup processes are doing ( We have more detailed troubleshooting docs for IIS hosting here: https://docs.microsoft.com/en-us/aspnet/core/test/troubleshoot-azure-iis?view=aspnetcore-3.1 |
I used Serilog and try/catch structures to instrument the application to find what portion was crashing or causing us to take longer than 120 seconds but all of the logs showed that nothing was slow or crashing. We went through the I finally "fixed" this by adding this to the .csproj file:
So with this being the only change I made, now the web application appears to startup and run normally on this server. What's even more strange is that we have two other virtual directories running on the same web server running beta versions of the same code and both work using in-process hosting without an issue. Even though it's back to functional, any ideas on the root cause as to why it cannot run in-process but the same code runs fine with out-of-process hosting? |
Are you calling If you're unsure, you can share your |
Yes, we call Here's the full code for Program.cs
And here's the full code for Startup.cs
|
How long does that |
yes I instrumented the code by just spreading out Serilog statements throughout the startup logic. I took that out when I determined that this code would not take longer than 120 seconds. I just pulled that branch and reran it and the total startup time is about 10 seconds
This code works fine when running out of process but when the only thing I change is to run in-process, then it always throws |
Have you tried increasing the startup time limit anyway (as a way of exploring the possibilities)? Is there any way you could provide a runnable sample that reproduces the problem? It's very difficult to see where the delay could be coming from without full context. Let me know if you're able to share something but want to keep it confidential. |
I was using the default .net core 3.1 web template with Blazor and got the same error in azure app service hosting. Below solved by |
@sunnylnct007 this error message can have a lot of different causes. Unless your app is the same one as @akiander, I'd suggest filing a new bug instead and providing as much detail as you can (errors from the Windows Event Log, etc.). If they end up having the same root cause, we can figure that out later :). |
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. |
Update on this ... even when running out-of-process, we just saw this web application fail on one of the two web servers. Looking closer, I see this error logged:
Checking process explorer on the other web server, the thread count is pretty high (approx. 1300) so I took a minidump and checked the parallel stacks window in Visual Studio and I'm seeing most of the threads seem to be related to Azure Application Insights logging components. I'm wondering if that's a factor here. |
Do you have any places where you are doing blocking calls (like |
Something has gone completely haywire in your logic if causes app insights to spin up that many threads and the console logger to have 500 background threads. The logging configuration might be busted. |
Taking a process dump and trying to see how you ended up with 500 console loggers might show what's going on. |
The configuration is shown above in the The only place we differ is with our custom telemetry although that is nothing new to this app:
I guess I'll try removing this and see what happens although we depend on it for our production monitoring and triage. Do you see anything here that might cause this? |
No I would take a process dump and try to figure out what is rooting the instances of the ConsoleLogProvider (or ILoggerFactory). That might give a clue as to what is happening. |
Seems like it is rooted by TokenCleanupHost.StartInternalAsync which is a token cleanup feature we leverage in Identity Server so I'm exploring that possibility as well. |
What exactly is being rooted? Can you look at the managed memory? If you need some help looking at the memory dump I can help, send me email david.fowler at microsoft.com |
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>(); |
I have removed the calls to |
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:
Looking in the event log, we see this:
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?
The text was updated successfully, but these errors were encountered: