![](/img/trans.png)
[英]DropDownList Error, System.InvalidOperationException
[英]System.InvalidOperationException error reason?
我在 .Net6 中使用 BigBlueButtonAPI.NET Package。
在我的 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 中我看到了這個錯誤:
這是答案。 也許對其他人也有幫助。 我添加了builder.Services.AddHttpClient();
在代碼之前:
builder.Services.AddHttpClient();
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());
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.