我将Lamar用作.Net Core(2.2)Web API的DI。
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:\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
答案 0 :(得分:0)
此错误是由于我刚刚将 ConfigureServices 调用替换为ServiceRegistry而引起的。我实际上应该使用 ConfigureContainer :
public void ConfigureContainer(ServiceRegistry services)
{ }