xunit“无法加载类型"错误 [英] xunit "could not load type" error

查看:51
本文介绍了xunit“无法加载类型"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承了一个项目,测试运行正常.今天,我创建了一个新类,并在尝试在测试中使用此类时出现xunit错误.

I inherited a project and the tests ran fine. Today, I created a new class, and xunit errors out when I try to use this class in a test.

测试项目和应用程序都针对.NET Framework 4.6.1.

Both the test project and the app are targeting .NET Framework 4.6.1.

我确实在解决方案和测试项目上都进行了清理和重建,但是仍然出现错误.

I do clean and rebuild on the both the solution and the test project, but I still get the error.

错误:

无法从程序集"MyApp,Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null"中加载类型'MyNewClass'.

Could not load type 'MyNewClass' from assembly 'MyApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

project.json:

"buildOptions": {
  "warningsAsErrors": true
},
"testRunner": "xunit",
"dependencies": {
  "xunit": "2.2.0-beta4-build3404",
  "dotnet-test-xunit": "2.2.0-preview2-build1029",
  "MyApp": "1.0.0-*",
  "Microsoft.EntityFrameworkCore.InMemory": "1.0.0",
  "NSubstitute": "1.9.2"
},

"frameworks": {
    "net461": {
    }
}

任何人都知道如何解决此问题吗?

Anyone have any ideas how to fix this?

推荐答案

所以,我的问题是,即使我进行了清理和重建,MyApp.dll也没有得到更新/重新创建.我必须物理删除MyApp \ test \ MyApp.Tests \ bin \ Debug \ net461 \ win7-x86

So, my problem was that MyApp.dll was not getting updated/re-created, even after I did a clean and rebuild. I had to physically delete the files (including MyApp.dll) in MyApp\test\MyApp.Tests\bin\Debug\net461\win7-x86

这篇关于xunit“无法加载类型"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆