我使用 Lamar 作为 .Net Core (2.2) Web API 的 DI。
程序.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:\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