我在使用 .NET Core 3.0 实现 Ocelot 时遇到问题,当我尝试在我的程序类中添加 ocelot(按照文档指定应该执行的操作)时,vs2019 显示了此错误:
“IServiceCollection”不包含“AddOcelot”的定义或接受“IServiceCollection”类型的第一个参数的可访问扩展方法“AddOcelot”(是否缺少任何使用指令或程序集引用?),
UseOcelot()方法也会重复此错误
public class Program
{
public static void Main(string[] args)
{
new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.ConfigureAppConfiguration((context, config) =>
{
config
.SetBasePath(context.HostingEnvironment.ContentRootPath)
.AddJsonFile("appsettings.json", true, true)
.AddJsonFile($"appsettings.{context.HostingEnvironment.EnvironmentName}.json", true, true)
.AddJsonFile("ocelot.json")
.AddEnvironmentVariables();
}).ConfigureServices(s => {
s.AddOcelot().AddConsul();
}).ConfigureLogging((hostingContext, logging) =>
{
logging.AddConsole();
})
.UseIIS()
.Configure(app =>
{
app.UseOcelot().Wait();
})
.Build().Run();
}
}
Run Code Online (Sandbox Code Playgroud)
我该怎么解决这个错误?,我已经安装了 Nuget 包 Ocelot 版本 13.8.0 和 Ocelot.Provider.Consul 版本 13.8.0。