【发布时间】:2022-02-27 20:10:50
【问题描述】:
我在 .Net6 中使用 BigBlueButtonAPI.NET 包。
在我的 appsetting 中,我声明了这些变量:
\"BigBlueButtonAPISettings\": {
\"ServerAPIUrl\": \"https://myserver.com/bigbluebutton/api/\",
\"SharedSecret\": \"my shared secret here\"
}
在我的 program.cs 我写了这些代码:
builder.Services.Configure<BigBlueButtonAPISettings>
(builder.Configuration.GetSection(\"BigBlueButtonAPISettings\"));
builder.Services.AddScoped<BigBlueButtonAPIClient>(provider =>
{
var settings = provider.GetRequiredService<IOptions<BigBlueButtonAPISettings>>().Value;
var factory = provider.GetRequiredService<IHttpClientFactory>();
return new BigBlueButtonAPIClient(settings, factory.CreateClient());
});
当我想在我的应用程序中调用 API 时,在 program.cs 中我看到了这个错误:
-
异常消息已经告诉您:没有注册类型
IHttpClientFactory的服务。你认为你在哪里注册? -
(我怀疑你只需要打电话给
builder.Services.AddHttpClient()。) -
对我来说,错误消息是自我解释的,您需要注册所需的服务
-
请:read the manual。软件开发需要您自己的研究。
-
@JHBonarius 在提问之前我进行了搜索。
标签: c# asp.net .net-6.0 bigbluebutton