c# - 如何在 .net core 2.2 中使用依赖注入添加 IEndpointsOperations 接口
问题描述
我想使用.net core 2.2中可用的依赖注入接口中的LoadContentAsync
方法。IEndpointOperations
请分享一些代码示例。我尝试添加AddSingleton
/并尝试在控制器构造函数中使用它AddTransient
。Startup.cs
但我得到以下错误,
未处理的异常:System.ArgumentException:无法为服务类型“Microsoft.Azure.Management.Cdn.IEndpointsOperations”实例化实现类型“Microsoft.Azure.Management.Cdn.IEndpointsOperations”。
解决方案
需要在启动类中让系统知道某个接口的实现类。例如:
public override void Configure(IFunctionsHostBuilder builder)
{
builder.Services.AddSingleton<IClass1, Class1>();
}
可以知道接口IEndpointsOperations的实现类吗?
推荐阅读
- javascript - 随机 - 为测验中的错误答案添加偏见(javascript)
- r - 在ggplot中为直方图添加边框
- javascript - stopPropagation() 是否从捕获阶段停止执行事件?
- java - JAVA构造函数不接受枚举值
- django - “运行 manage.py 任务”和 .env 文件环境变量
- javascript - 如何在应用内禁用 Chrome 节流后台选项卡?
- hibernate - 像休眠标准没有给出适当的结果
- java - FileNotFoundException(不是目录)
- gatsby - 我如何管理 gatsby 中越来越多的图像
- javascript - Vue.js 3.0:从方法读取和设置对象属性