I am using Lamar as the DI for .Net Core (2.2) Web API.
Program.cs
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseLamar()
.UseStartup<Startup>();
}
When I have following code at Startup.cs the program starts fine.
public void ConfigureServices(IServiceCollection services)
{ }
As soon as I change the method to this
public void ConfigureServices(ServiceRegistry services)
{ }
Starting the Web API will show
HTTP Error 500.30 - ANCM In-Process Start Failure
In Event Viewer there are couple of Errors.
Application '/LM/W3SVC/2/ROOT' with physical root 'C:\xxx\path\to\Web.API\' hit unexpected managed exception, exception code = '0xe0434352'. Please check the stderr logs for more information.
and
Application '/LM/W3SVC/2/ROOT' with physical root 'C:\xxx\path\to\Web.API\' failed to load clr and managed application. CLR worker thread exited prematurely
This error is caused because I just replaced ConfigureServices call with the ServiceRegistry. I should actually use ConfigureContainer:
public void ConfigureContainer(ServiceRegistry services)
{ }