使用ServicereGistry时,Lamar会导致500.30错误



我正在使用lamar作为.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>();
    }

当我在startup.cs上有以下代码时,程序开始正常。

        public void ConfigureServices(IServiceCollection services)
        { }

一旦我将方法更改为

        public void ConfigureServices(ServiceRegistry services)
        { }

启动Web API将显示

HTTP Error 500.30 - ANCM In-Process Start Failure

在活动查看器中有两个错误。

Application '/LM/W3SVC/2/ROOT' with physical root 'C:xxxpathtoWeb.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:xxxpathtoWeb.API' failed to load clr and managed application. CLR worker thread exited prematurely

引起此错误,因为我刚刚用ServicereGistry替换了 configerservices 调用。我实际上应该使用 configurecontainer

        public void ConfigureContainer(ServiceRegistry services)
        { }

最新更新