title: HTTP Error 500.30 - ANCM In-Process Start Failure On a localhost .net core 3.1.1 API C#
body: <p>Windows Error Log:</p>
  <blockquote>
  <p>failed to load coreclr. Exception message: CLR worker thread exited
  prematurely</p>
  </blockquote>
  <p>Details:</p>
  <blockquote>
  <p>Application 'EnterpriseReportsAPI' with physical root
  '...\Repos\InternalReportsAPI\EnterpriseReportsAPI' failed to load
  coreclr. Exception message: CLR worker thread exited prematurely<br />
  Process Id: 10688.     File Version: 13.1.19350.1. Description: IIS
  ASP.NET Core Module V2 Request Handler. Commit:
  e276c8174b8bfdeb70efceafa81c75f8badbc8db</p>
  </blockquote>
  <p>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.</p>
  <pre><code>public class Connections : IConnections
      {
          private readonly ISecurityServiceHelper _securityServiceHelper;
  
          public Connections(ISecurityServiceHelper securityServiceHelper)
          {
              _securityServiceHelper = securityServiceHelper;
          }
          public string GetSqlConnectionString(string[] creds)
          {
              return _securityServiceHelper.GetSqlConnectionStringAsync(creds).Result;
          }
      }
  </code></pre>
  <p>Then in the startup.cs I change it to:</p>
  <pre><code>public Startup(IConfiguration configuration, IConnections connections)
          {
              Configuration = configuration;
              Connections = connections;
          }
  
          private readonly IConfiguration Configuration;
          private readonly IConnections Connections;
  </code></pre>
  <p>Then utilize those properties inside the following:</p>
  <pre><code>string[] creds =
              {
                          Configuration.GetSection(&quot;ApplicationCreds&quot;).GetSection(&quot;appId&quot;).Value,
                          Configuration.GetSection(&quot;ApplicationCreds&quot;).GetSection(&quot;appToken&quot;).Value,
                          Configuration.GetSection(&quot;ConnectionString&quot;).GetSection(&quot;connectionString&quot;).Value
              };
              services.AddDbContext&lt;InternalReportsContext&gt;(options =&gt;
                  options.UseSqlServer(Connections.GetSqlConnectionString(creds)));
  </code></pre>
  <p>I have declared the two services as follows:</p>
  <pre><code>services.AddScoped&lt;IConnections, Connections&gt;();
  
  services.AddScoped&lt;IConfiguration&gt;(sp =&gt;
              {
                  IConfigurationBuilder configurationBuilder = new ConfigurationBuilder();
                  configurationBuilder.AddJsonFile(&quot;appsettings.json&quot;);
                  return configurationBuilder.Build();
              });
  </code></pre>
  <p>So I have looked at a few posts (notably [this])(<a href="https://stackoverflow.com/questions/53811569/http-error-500-30-ancm-in-process-start-failure">HTTP Error 500.30 - ANCM In-Process Start Failure</a>) 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.</p>
  <p>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.</p>
  <p>If I change the properties to OutOfProcess as suggested by the other &quot;related&quot; post I get the following:</p>
  <p><a href="https://i.stack.imgur.com/HVJ68.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HVJ68.png" alt="enter image description here" /></a></p>
  <p><a href="https://stackoverflow.com/questions/53811569/http-error-500-30-ancm-in-process-start-failure">This</a> 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.</p>
  <p><a href="https://i.stack.imgur.com/2v4ut.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2v4ut.png" alt="enter image description here" /></a></p>