我正在尝试使单元测试在.NET Core 1.0解决方案中运行。当我运行一个空测试时,它可以正常工作。但是,一旦我尝试创建ApplicationDbContext的新实例,测试就会失败,并带有以下异常:
System.IO.FileLoadException : Could not load file or assembly 'System.Interactive.Async, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263'. The located assembly's 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)
不确定为什么根本需要System.Interactive.Async,但是我将其作为依赖项添加到我的Tests项目中。但是,该dll似乎没有复制到生成的bin\Debug\netcoreapp1.0文件夹中。如果我手动将其复制到那里,则效果完全相同。有什么想法我还能做些什么来使其正常工作?
最佳答案
对我来说,抛出此错误是因为在我的project.json中,我已正确添加:
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-*",
使用核心,但我没有删除此行,它在其他依赖项之间的文件中更靠后:
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
删除该行后,我就越过了这个错误。
关于.net - xunit和System.Interactive.Async,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38206239/