【发布时间】:2020-01-10 19:28:11
【问题描述】:
我有这门课:
public class ApiService
{
public bool Success { get; set; }
public object Data { get; set; }
public ApiService(bool success, object data)
{
this.Success = success;
this.Data = data;
}
}
我尝试使用这一行将其添加到 startup.cs 中的服务:
services.AddSingleton<ApiService>();
但我有这个例外:
Unhandled exception. System.AggregateException:
Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: ApiService Lifetime: Singleton ImplementationType:
ApiService':
Unable to resolve service for type 'System.Boolean' while attempting to activate ApiService'.)
如果有人可以解决此问题,请提前感谢。
最好的问候。
【问题讨论】:
标签: c# asp.net-core service boolean asp.net-core-3.0