Lamar 在使用 ServiceRegistry 时导致 500.30 错误

Lamar causes 500.30 error when using ServiceRegistry

我正在使用 Lamar 作为 .Net Core (2.2) Web 的 DI 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>();
    }

当我在 Startup.cs 处有以下代码时,程序可以正常启动。

        public void ConfigureServices(IServiceCollection services)
        { }

只要我把方法改成这个

        public void ConfigureServices(ServiceRegistry services)
        { }

启动网络API将显示

HTTP Error 500.30 - ANCM In-Process Start Failure

在事件查看器中有几个错误。

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.

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

这个错误是因为我刚刚用 ServiceRegistry 替换了 ConfigureServices 调用。我实际上应该使用 ConfigureContainer:

        public void ConfigureContainer(ServiceRegistry services)
        { }