【问题标题】:.NET Core 3.0 migration error IAsyncEnumerable<T> exists in both System.Interactive.Async and System.Runtime.NET Core 3.0 迁移错误 IAsyncEnumerable<T> 同时存在于 System.Interactive.Async 和 System.Runtime
【发布时间】:2019-10-29 08:17:31
【问题描述】:

我正在尝试将项目从 .net core 2.2 迁移到 3.0。

我收到错误:

错误 CS0433 类型 'IAsyncEnumerable' 存在于两者中 'System.Interactive.Async,版本=3.2.0.0,文化=中性, PublicKeyToken=94bc3704cddfc263' 和 'System.Runtime, Version=4.2.1.0

我在这里尝试了一个建议: https://github.com/aspnet/EntityFrameworkCore/issues/15047 建议强制更新到 System.Interactive.Async 4.0.0。 (我将此引用添加到我的项目中)。

但是我还有另一个错误: 对“IAsyncEnumerable”类型的引用声称它是在“System.Interactive.Async”中定义的,但找不到它

我正在使用 IAsyncQueryProvider,它似乎是导致问题的原因。

我在 2.2 中没有这些问题,目前找不到任何解决方法。

我还尝试强制更新到 System.Runtime 4.3.1,但没有帮助。

【问题讨论】:

  • 该问题是针对旧预览版的。我无法在 .NET Core 3.0 项目中重现 EF Core 3 的任何问题。您是否已将 EF Core 升级到 3.0?
  • 是的,你的建议奏效了。其实我没有升级到EF Core 3.0,我加了,看来.NET CORE 2.2中不需要这个引用

标签: c# .net-core .net-core-3.0


【解决方案1】:

作为一个在 .NET Core 2.2 上偶然发现但没有迁移到 3+ 的人,我在 same issue referenced above 上找到了另一个解决方案。 引用的项目文件在此评论后被修改,所以here's a direct link

就我而言,我将此目标添加到项目文件中:

<Target Name="AddAssemblyAliasToReactiveAsync"
        AfterTargets="ResolveAssemblyReferences"
        Condition="'$(TargetFramework)' == 'netcoreapp2.2'">
  <ItemGroup>
    <ReferencePath Condition=" '%(FileName)' == 'System.Interactive.Async' ">
      <Aliases>reactive</Aliases>
    </ReferencePath>
  </ItemGroup>
</Target>

【讨论】:

    【解决方案2】:

    Panatiotis 的建议有效,我添加了对 Microsoft.EntityFrameworkCore 3.0 的引用并且它有效。对于我的情况,.NET Core 2.2 中不需要此引用。

    【讨论】:

      【解决方案3】:

      虽然问题已得到解答,但我在这里找到了:https://github.com/dotnet/efcore/issues/14239 一个与此问题相似且与我的问题几乎相同的人。

      netcoreapp3.1 项目使用 EntityFrameworkCore (3.1.1) 和 IAsyncEnumerable 接口。 我的构建以这个错误结束:

      error CS0433: The type 'IAsyncEnumerable' exists in both 'Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' and 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
      

      问题是由使用 nuget restore 命令(不是 dotnet restore)引起的,并且我使用的是旧版本的 nuget.exe。升级到最新的 nuget.exe 修复了构建。

      【讨论】:

      • 谢谢,这是我需要的解决方案 :)
      猜你喜欢
      • 2020-03-05
      • 1970-01-01
      • 2023-03-26
      • 1970-01-01
      • 1970-01-01
      • 2020-08-22
      • 2021-04-23
      • 2020-01-26
      • 1970-01-01
      相关资源
      最近更新 更多