0

Windows Error Log:

failed to load coreclr. Exception message: CLR worker thread exited prematurely

Details:

Application 'EnterpriseReportsAPI' with physical root '...\Repos\InternalReportsAPI\EnterpriseReportsAPI' failed to load coreclr. Exception message: CLR worker thread exited prematurely
Process Id: 10688. File Version: 13.1.19350.1. Description: IIS ASP.NET Core Module V2 Request Handler. Commit: e276c8174b8bfdeb70efceafa81c75f8badbc8db

Every thing works more or less fine until I try to further the dependency injection by changing my static connectionstring helper into an injected service.

public class Connections : IConnections
    {
        private readonly ISecurityServiceHelper _securityServiceHelper;

        public Connections(ISecurityServiceHelper securityServiceHelper)
        {
            _securityServiceHelper = securityServiceHelper;
        }
        public string GetSqlConnectionString(string[] creds)
        {
            return _securityServiceHelper.GetSqlConnectionStringAsync(creds).Result;
        }
    }

Then in the startup.cs I change it to:

public Startup(IConfiguration configuration, IConnections connections)
        {
            Configuration = configuration;
            Connections = connections;
        }

        private readonly IConfiguration Configuration;
        private readonly IConnections Connections;

Then utilize those properties inside the following:

string[] creds =
            {
                        Configuration.GetSection("ApplicationCreds").GetSection("appId").Value,
                        Configuration.GetSection("ApplicationCreds").GetSection("appToken").Value,
                        Configuration.GetSection("ConnectionString").GetSection("connectionString").Value
            };
            services.AddDbContext<InternalReportsContext>(options =>
                options.UseSqlServer(Connections.GetSqlConnectionString(creds)));

I have declared the two services as follows:

services.AddScoped<IConnections, Connections>();

services.AddScoped<IConfiguration>(sp =>
            {
                IConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
                configurationBuilder.AddJsonFile("appsettings.json");
                return configurationBuilder.Build();
            });

So I have looked at a few posts (notably [this])(HTTP Error 500.30 - ANCM In-Process Start Failure) on changing the InProcess to OutOfProcess however that gives me other weird issues. I am not sure what changes when I make these changes under the hood and it has been driving me crazy for several days.

I had started the API in 2.2 but it is now 3.1.1 and I removed all the 2.2 references from the csproj file as well.

If I change the properties to OutOfProcess as suggested by the other "related" post I get the following:

enter image description here

This seems to be very close to my issue but I can't figure out which reference has a dependency on the Core 2.2. I have removed all the 2.2 references from the csproj and I don't see anything that jumps out in my references. Or I am looking in the wrong place.

enter image description here

Slagmoth
  • 173
  • 1
  • 10
  • Does this answer your question? [HTTP Error 500.30 - ANCM In-Process Start Failure](https://stackoverflow.com/questions/53811569/http-error-500-30-ancm-in-process-start-failure) – Lukasz Szczygielek Nov 24 '20 at 21:26
  • @Hostel I had read that one and tried to make the suggested changes to the csproj and changed the properties to OutProcess but it does some other wacky pop-up error and doesn't even start the API locally. – Slagmoth Nov 24 '20 at 21:33
  • Did you install hosting bundle for your version of .net core? – Lukasz Szczygielek Nov 24 '20 at 21:35
  • I have the 5.0 installed how as I was trying to update some of the nugets thinking maybe I was just out of date on a few things. I had not considered doing that since it was working before I made these seemingly innocuous changes, I don't understand how something that seems so simple could cause such a breaking issue. I will go find the hosting bundle for 3.1 and try that. – Slagmoth Nov 24 '20 at 21:38
  • @Hostel No joy on the stick. I did a rebuild and iisreset to be sure and I get the same error. And the Windows Error Logs are the same as well. – Slagmoth Nov 24 '20 at 21:48
  • Not sure if it matters but after these errors it takes FOREVER for the process to stop when I try and end the debugging. It seems to have some sort of difficulty detaching from the process or IIS or something. – Slagmoth Nov 24 '20 at 21:50
  • Event Viewer has exception message with details? – Lukasz Szczygielek Nov 25 '20 at 00:12
  • If you can't find root cause then maybe let's try deploy hello world for 3.1 - it will tell if environment is good. Now it's hard to tell if issue is with project migration or environment. – Lukasz Szczygielek Nov 25 '20 at 00:19
  • @Hostel Added the details of the last error I received. I am trying to look into the references and finding out if I missed one that might have referenced 2.2... however, if someone can explain how it worked before but suddenly doesn't with that error with only that change that would be great. I want to learn the under the hood "magic" for some things. – Slagmoth Nov 25 '20 at 00:19
  • @Hostel The API works more or less perfectly until I make this change. I have been tracking down an intermittent concurrency issue and have been refactoring the IoC references that I missed here and there and run into this error when I make certain changes. – Slagmoth Nov 25 '20 at 00:21
  • Does you App Pool has bitness same as installed runtime? (https://weblog.west-wind.com/posts/2020/Nov/25/Watch-out-for-NET-Core-Runtime-Bitness-for-IIS-Installs) – Lukasz Szczygielek Nov 27 '20 at 14:03
  • @Hostel So I have Any CPU for the application setting in the properties and I have "prefer 32" off. In the AppPool I have "Enable 32-bit Applications" set to false. If I understand the article correctly that should mean they match. I run dotnet --info and get very similar results as he does as well. – Slagmoth Nov 30 '20 at 14:14

0 Answers0