Xunit and System.Interactive.Async

I am trying to get unit tests running in my .NET Core 1.0 solution. When I run an empty test, it works fine. However, as soon as I try to create a new instance of ApplicationDbContext, the test will fail with the following exception:

System.IO.FileLoadException : Could not load file or assembly 'System.Interactive.Async, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263'. The located assembly manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Stack Trace: at Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServiceCollectionExtensions.AddQuery(IServiceCollection serviceCollection) at Microsoft.EntityFrameworkCore.Infrastructure.EntityFrameworkServiceCollectionExtensions.AddEntityFramework(IServiceCollection serviceCollection) at Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache.<>c__DisplayClass4_0.<GetOrAdd>b__1(Int64 k) at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) at Microsoft.EntityFrameworkCore.DbContext..ctor(DbContextOptions options) (2 more stack trace lines from my code) 

I don’t know why System.Interactive.Async is needed at all, but I added it as a dependency on my Tests project. However, the dll is not copied to the bin \ Debug \ netcoreapp1.0 folder during assembly. If I copy it manually, the effect will be the same. Any ideas what else I can do to make it work?

+6
source share
7 answers

For me, this error was thrown because in my .json project I correctly added:

 "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-*", 

to use the kernel, but I did not delete this line, which was further in my file between the other dependencies:

 "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final", 

As soon as I deleted this line, I missed this error.

+7
source

I am using SQLite and Entity Framework Core. I came across the following exception.

 Could not load file or assembly 'System.Interactive.Async, Version=3.0.3000.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263' or one of its dependencies 

I installed all the necessary packages, but this did not solve.

There is a package called System.Interactive.Async (Ix Async) that can be installed via Nuget

Then my runtime exception was resolved.

+5
source

For me it was a strange line

EntityFramework.InMemory

optionally to Microsoft.EntityFrameworkCore.InMemory in project.json . As soon as I remove it started working

+3
source

In my case, the problem was the same as mentioned above - I found the forgotten dependency " EntityFramework.MicrosoftSqlServer " in a related project.

To investigate the problem, I use my project project.lock.json . There were 2 packages with System.Interactive.Async.dll - Ix-Async / 1.2.5 and System.Interactive.Async/3.0.0 .

Then look at which package depends on Ix-Async (still viewed in project.lock.json ) and find that it is EntityFramework.Core / 7.0.0-rc1-final. Since there were no more packages dependent on EntityFramework.Core , I realized that I have EntityFramework.Core in some of my own dependencies (one of my project.json projects)

+2
source

I'm not 100% sure, but I think it might be a mistake when you need to restart Visual Studio after updating NuGet packages such as System.Interactive.Async. I ran into the same error and tried setting up version redirects in App.config. I could not get it to work. This all the time gave me the error that you cannot load the assembly. This gave me an error even when downgrading to what she was looking for and rebuilding. I restarted Visual Studio, and then everything was fine. The only thing I can think of, maybe the testing runner has something cached in memory. I am using Visual Studio 2017.

0
source

I had a similar problem and had to update the redirect binding in the app.config file to point to the corresponding version, as shown below:

 <dependentAssembly> <assemblyIdentity name="System.Interactive.Async" publicKeyToken="94bc3704cddfc263" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-3.0.3000.0" newVersion="3.0.1000.0" /> </dependentAssembly> 

Take a look at oldVersion and newVersion in the above code example.

0
source

For those who may be newer, it can be as simple as rebuilding NuGet packages at the project level.

In your solution, right-click the project and select the Restore packages option.

-one
source

All Articles