Đoạn mã sau được lấy từ các ví dụ tại docs.asp.net.Cấu hình các tùy chọn từ IConfigurationRoot không hoạt động?
public void ConfigureServices(IServiceCollection services)
{
// Setup options with DI
services.AddOptions();
// Configure MyOptions using config
services.Configure<MyOptions>(Configuration);
// Configure MyOptions using code
services.Configure<MyOptions>(myOptions =>
{
myOptions.Option1 = "value1_from_action";
});
Các cuộc gọi đến services.Configure<MyOptions>(Configuration);
gây ra một lỗi biên dịch:
cannot convert from 'Microsoft.Extensions.Configuration.IConfigurationRoot' to 'System.Action'
thủ thiết lập các tùy chọn hoạt động tốt. Tôi có thiếu một cái gì đó thực sự rõ ràng ở đây?
Cụ thể hơn, là sự phụ thuộc trong project.json – robbpriestley
Làm việc cho tôi. –