title: ASP .NET Core IIS Deploy IIS AspNetCore Module Error: CLR worker thread exited prematurely
body: <p>I give IIS every feature in windows, but if your have advice please share me. Anyway I want deploy on IIS Lan server. But i cant. I working on two days this problems. I dont know how can fix this.I use &quot;.net.5.0&quot;.
  My application codes like that</p>
  <p><strong>Program.cs</strong></p>
  <pre><code>public class Program
  {
      public static void Main(string[] args)
      {
          var host = new WebHostBuilder()
              .UseKestrel()
              .UseContentRoot(Directory.GetCurrentDirectory())
              .UseIISIntegration().UseUrls(&quot;http://localhost:8080/&quot;)
              .UseStartup&lt;Startup&gt;()
              .Build();
      }  
  }
  </code></pre>
  <p>Startup</p>
  <pre><code>namespace EcommerceGastro.API
  {
      public class Startup
      {
          public Startup(IConfiguration configuration)
          {
              Configuration = configuration;
          }
  
          public IConfiguration Configuration { get; }
  
          // This method gets called by the runtime. Use this method to add services to the container.
          public void ConfigureServices(IServiceCollection services)
          {
  
              services.AddDbContext&lt;GastroDB&gt;();
              services.AddScoped&lt;IMainCategoryService, MainCategoryService&gt;();
              services.AddScoped&lt;IProductService, ProductService&gt;();
              services.AddScoped&lt;ICategoryService, CategoryService&gt;();
              services.AddScoped&lt;IUploadImageService, UploadImageService&gt;();
              services.AddAutoMapper(typeof(AutoMapperProfile));
              services.AddControllers();
              services.AddControllers().AddNewtonsoftJson(opt =&gt;
              {
                  opt.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
              });
          }
  
          // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
          public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
          {
              if (env.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
              }
  
              app.UseRouting();
              app.UseStaticFiles();
              //Initiliazer.HomePageControl().Wait();
              app.UseAuthorization();
  
              app.UseEndpoints(endpoints =&gt;
              {
                  endpoints.MapControllers();
              });
          }
      }
  }
  
  </code></pre>
  <p>appsettings.json</p>
  <pre><code>{
    &quot;Logging&quot;: {
      &quot;LogLevel&quot;: {
        &quot;Default&quot;: &quot;Information&quot;,
        &quot;Microsoft&quot;: &quot;Warning&quot;,
        &quot;Microsoft.Hosting.Lifetime&quot;: &quot;Information&quot;
      }
    },
    &quot;AllowedHosts&quot;: &quot;*&quot;,
    &quot;ConnectionStrings&quot;: { &quot;DefaultConnection&quot;: &quot;server=.; database=GastroDB; user id=sa; password=123;&quot; }
  }
  
  
  </code></pre>
  <p>My publish settings:
  <a href="https://i.stack.imgur.com/RwFa3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RwFa3.png" alt="enter image description here" /></a></p>
  <p>My iis settings:
  <a href="https://i.stack.imgur.com/JOmUB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JOmUB.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/hDN9P.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hDN9P.png" alt="enter image description here" /></a></p>
  <p><a href="https://i.stack.imgur.com/YrGQq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/YrGQq.png" alt="enter image description here" /></a></p>
  <p>Paylaşılmıyor = Dont share
  <a href="https://i.stack.imgur.com/OeHaz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/OeHaz.png" alt="enter image description here" /></a></p>
  <p>Yetkilendirme = authority
  <a href="https://i.stack.imgur.com/PLvI0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PLvI0.png" alt="enter image description here" /></a></p>
  <p>My Error :</p>
  <pre><code>Application '/LM/W3SVC/1/ROOT' with physical root 'C:\Users\Tuğçe\Desktop\iisDeneme\EcommerceGastro.API\bin\Release\net5.0\publish\' failed to load coreclr. Exception message:
  CLR worker thread exited prematurely
  </code></pre>
  <pre><code>Application '/LM/W3SVC/1/ROOT' with physical root 'C:\Users\Tuğçe\Desktop\iisDeneme\EcommerceGastro.API\bin\Release\net5.0\publish\' has exited from Program.Main with exit code = '0'. Please check the stderr logs for more information.
  </code></pre>
  <p>And i browse this iis web app its open but look like :</p>
  <pre><code>HTTP Error 500.30 - ASP.NET Core app failed to start
  Common solutions to this issue:
  The app failed to start
  The app started but then stopped
  The app 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
  </code></pre>