Lamar causes 500.30 error when using ServiceRegistry

0

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
.net
.net-core
lamar
asked on Stack Overflow May 6, 2019 by Juho Rutila

1 Answer

0

This error is caused because I just replaced ConfigureServices call with the ServiceRegistry. I should actually use ConfigureContainer:

        public void ConfigureContainer(ServiceRegistry services)
        { }
answered on Stack Overflow May 6, 2019 by Juho Rutila

User contributions licensed under CC BY-SA 3.0