.net - Lamar 在使用 ServiceRegistry 时导致 500.30 错误
问题描述
我使用 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
解决方案
这个错误是因为我刚刚用ServiceRegistry 替换了ConfigureServices调用。我实际上应该使用ConfigureContainer:
public void ConfigureContainer(ServiceRegistry services)
{ }
推荐阅读
- sql-server - 在 SQL Server 2008 中的 Order by 子句中以内部大小写连接条件
- android - fontFamily 'Arial' 不是使用 react-native-textinput-effects 的系统字体
- sql-server - 全文未索引 varbinary 列(使用 html)
- java - 如何使用 iText 7 为我的 PDF 添加背景颜色?
- botframework - Bing Maps API - mapArea:此参数值超出范围
- spring - 如何在 spark, spring 应用程序中读取所有具有给定前缀的属性文件?
- ios - 在哪些情况下 viewWillAppear(_ animated: Bool) 方法不会被调用,即使 viewDidLoad() 已经被调用?
- excel - 更改重复行中的单元格值
- cuba-platform - 如何在古巴框架的表格中点击一行?
- php - 用json添加一行DataTable