【发布时间】:2016-07-05 14:37:23
【问题描述】:
我正在尝试在我的 .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,但我将它作为依赖项添加到了我的测试项目中。但是,该 dll 似乎没有在构建时复制到 bin\Debug\netcoreapp1.0 文件夹。如果我手动复制它,效果完全一样。任何想法我还能做些什么来让它工作?
【问题讨论】:
-
您是否已将此添加到您的测试 json 文件“portable-net45+win8”中?
-
请贴一些代码。
-
有同样的问题,但来自我的业务逻辑课。我的 project.json 框架导入中有portable-net45+win8。
标签: .net entity-framework .net-core xunit.net