Efcore: System.Interactive.Async dependency breaks .NET Core 3.0 IAsyncEnumerator in .NET Core 3.0 preview 3

Created on 16 Mar 2019  路  19Comments  路  Source: dotnet/efcore

Currently, Microsoft.EntityFrameworkCore 3.0.0-preview3.19153.1 requires System.Interactive.Async 3.2.0. However, both System.Interactive.Async 3.2.0 and .NET Core 3.0 provide System.Collections.Generic.IAsyncEnumerator`1, preventing projects that use IAsyncEnumerator from building:

Severity Code Description Project File Line Suppression State
Error CS0433 The type 'IAsyncEnumerator' exists in both 'System.Interactive.Async, Version=3.2.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263' and 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Test.Services E:\Source\Test\Test\Test.Services\Import\EnumeratorAgnosticEnumerator.cs 10 Active

closed-duplicate customer-reported

Most helpful comment

I came across this error just now. I'm using .netcoreapp3.1 and simply using IAsyncEnumerable interface gave me this error straightaway. If I'm not missing anything here then this error is kinda embarrassing for a production .net core release.

All 19 comments

Forcefully adding a dependency for System.Interactive.Async >= 4.0.0-preview* works around the issue, but I don't think it makes sense for EF Core 3.0.0-preview* to depend on System.Interactive.Async >= 3.2.0 when it really needs >= 4.0.0-preview*.

@smitpatel to follow up.

Duplicate of #14239

The thread has steps to get it to work.

For the 2nd comment duplicate of #14906

I am still currently running into this issue with EF Core 3.0. Is the suggested solution still to forcefully update System.Interactive.Async >= 4.0.0?

I also have this issue in Core 3.0.

forcefully updating to System.Interactive.Async 4.0.0 only helped partially. The error went away, but now I have another error:
Reference to type 'IAsyncEnumerable<>' claims it is defined in 'System.Interactive.Async', but it could not be found

I have a test class:
internal class TestAsyncQueryProvider : IAsyncQueryProvider

and it seems that IAsyncQueryProvider is causing the issue.

NOTE: I also tried forceably updating to System.Runtime 4.3.1 which did not help.

@shelbypereira Make sure that older versions of the IX package is not being referenced from somewhere. Likewise, make sure that all EF/Extensions/ASP.NET packages are updated to 3.0 versions. Also, be aware that starting with .NET Core 3.0, some types are now implemented by the .NET Core base class library due do support for async enumerations in the C# 8 compiler.

Thanks, your sugestion works, I actually did not have EF Core referenced, it seems I did not need it in .net Core, adding the reference to EF 3.0 worked.

Once I added System.Interactive.Async 4.0 - I now get

TypeLoadException: Could not load type 'System.Collections.Generic.IAsyncEnumerable`1' from assembly 'System.Interactive.Async, Version=4.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263'.

Once I added System.Interactive.Async 4.0 - I now get

TypeLoadException: Could not load type 'System.Collections.Generic.IAsyncEnumerable`1' from assembly 'System.Interactive.Async, Version=4.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263'.

Same thing happens to me

For runtime error "TypeLoadException: Could not load type 'System.Collections.Generic.IAsyncEnumerable`1' from assembly 'System.Interactive.Async, Version=4.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263'."

Remove the explicit addition of dependency to System.Interactive.Async 4.0 (as it does not have the type anymore and indirectly references it from Microsoft.Bcl.AsyncInterfaces)

And add to .csproj:

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

Inspired by comment in #14239, and corresponding reference to:
https://github.com/aspnet/EntityFrameworkCore/blob/v3.0.0-preview4.19216.3/Directory.Build.targets

I came across this error just now. I'm using .netcoreapp3.1 and simply using IAsyncEnumerable interface gave me this error straightaway. If I'm not missing anything here then this error is kinda embarrassing for a production .net core release.

I use EF2 in a separate library which i reference in the main project, and i can not use IAsyncEnumerable after that. It must be compatible with Net.Core 3.1, but it does not. I use it - because EF2.0 works with SQL 2008, but EF3.1 does not work.

Severity Code Description Project File Line Suppression State
Error CS0433 The type 'IAsyncEnumerable' exists in both 'System.Interactive.Async, Version=3.2.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263' and 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' PumpWeb C:\DATA\NEW_SVM\NSIWEB2APPLICATION\pumpMVC\PumpWeb\Utils\XmlGenResult.cs 29 Active

why is it SO HARD to use IAsyncEnumerable? I also encountered the same problem. I'm using .net core 3.0 by the way:

TypeLoadException: Could not load type 'System.Collections.Generic.IAsyncEnumerable`1' from assembly 'System.Interactive.Async, Version=4.1.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263'.

It's very frustrating and why do I even have to spend time searching everywhere to find how to a framework level API? Isn't it supposed to work out of the box?

_

Project in .net core 3.1

Using System.Interactive.Async latest version 4.1.1 I had the same problem.
Installing version 3.2.0 it worked.

For anyone running into this issue, if none of the solutions above work, the best way forward is to post a runnable code sample (including your csproj) in a new issue, and we'll investigate and assist. Unfortunately there isn't much we can do with a report that doesn't include a sample.

I have the same issue, using .Net core 3.1, my project has AddAssemblyAliasToReactiveAsync xml in csproj, still the compiler is confused as to which IAsyncEnumerable to use. Sample attached.
Sample.zip

Ok, so this may help someone... check all your various packages for references to Microsoft.EntityFrameworkCore.Relational.

In my case I had 2 different packages referencing that package. First one was Microsoft.EntityFrameworkCore.Tools. I installed that first and it installed the most recent version of this library.

Later I installed Oracle.EntityFrameworkCore which also reverences the ...Core.Relational package, but it references 2.1.1 (or something old anyway). It seems like installing that package updates your solution to always point to that old package and hence you get a compile error.

To work around this, uninstall both the .Tools and Oracle packages, then install the latest version of the .Relational package directly (this will lock that version from being over-ridden) then install the other packages.

Turns out the current stable version of Oracle.EntityFrameworkCore doesn't work with Core 3.1 so I had to switch to the pre-release Beta2. Seems to work though and for the Proof-of-concept I'm working on this will be fine. Will have to wait to go forward with core 3.1 until Oracle catches up.

Was this page helpful?
0 / 5 - 0 ratings