UseHttps扩展方法的歧义调用

问题描述 投票:0回答:1

在我的ASP.NET Core 3.1项目中,我在Program.cs中具有以下配置:

using System.Net;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

[...]

public static IHostBuilder CreateHostBuilder(string[] args) =>
    Host.CreateDefaultBuilder(args)
        .ConfigureWebHostDefaults(webBuilder =>
        {
            webBuilder.UseStartup<Startup>();
            webBuilder.ConfigureKestrel(options =>
            {
                options.Listen(IPAddress.Loopback, 5000, listenOptions =>
                {
                    listenOptions.UseHttps("debug.pfx", "password");
                });
            });
        })
        .ConfigureAppConfiguration((hostBuilderContext, config) =>
        {
            config.AddJsonFile("config-debug.json");
        });

参考包:

<PackageReference Include="AutoMapper" Version="9.0.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.3">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.10" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.1" />
<PackageReference Include="MoodleLti" Version="0.1.0" />
<PackageReference Include="MoodleLti.DependencyInjection" Version="0.1.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.1" />
<PackageReference Include="System.Linq.Async" Version="4.0.0" />

编译此会产生以下错误消息:

Error CS0121: The call is ambiguous between the following methods or properties:
'Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(Microsoft.AspNetCore.Server.Kestrel.Core.ListenOptions, string, string)' and
'Microsoft.AspNetCore.Hosting.ListenOptionsHttpsExtensions.UseHttps(Microsoft.AspNetCore.Server.Kestrel.Core.ListenOptions, string, string)'

...这对我来说没有多大意义。

我该如何解决?

c# asp.net-core asp.net-core-3.1 ambiguous-call
1个回答
0
投票

此问题是由NuGet依赖性引起的,该依赖性具有另一个依赖性,其中包括ASP.NET Core 2.0程序包。这些软件包与3.0软件包冲突,从而导致通话歧义错误。

我为受影响的库创建了一个问题,以添加ASP.NET Core 3.0支持。

推荐问答
热门问答
最新问答