WPF WebHostBuilder 不包含 UseKestrel 的定义

WPF WebHostBuilder does not contain definition for UseKestrel

我正在尝试根据 GitHub 使用 OIDC 实施单点登录,但我不断收到错误消息:

'WebHostBuilder' 不包含 'UseKestrel' 的定义,并且找不到可访问的扩展方法 'UseKestrel' 接受类型 'WebHostBuilder' 的第一个参数(您是否缺少使用指令或程序集引用?)

实施 SystemBrowser.cs 代码时

using IdentityModel.OidcClient.Browser;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

//other code
//simplified code extract below
IWebHost _host = new WebHostBuilder()
             .UseKestrel()
             .UseUrls(_url)
             .Configure(Configure)
             .Build();
//other code

根据 this 它应该是 Microsoft.AspNetCore.Hosting?

的一部分

是否缺少某些东西或需要安装 NuGet 包?到目前为止安装的软件包是:

如有任何帮助,我们将不胜感激。

默认的 asp.net 核心应用程序可以正常运行,因为框架中集成了 Microsoft.AspNetCore.Hosting 包和其他相关包。

我用 asp.net 核心测试了一个控制台应用程序,并重现了你的 issue.Install 和 Microsoft.AspNetCore.Hosting 以及 Microsoft.AspNetCore.Server.Kestrel

您可以通过搜索包名称在 NuGet 包管理器上下载,或者使用以下参考中的命令在包管理器控制台上下载:

https://www.nuget.org/packages/Microsoft.AspNetCore.Server.Kestrel/2.2.0?_src=template