微软单元测试失败,无法加载DLL测试 [英] Microsoft Unit Testing failure, unable to load DLL to test

查看:250
本文介绍了微软单元测试失败,无法加载DLL测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.NET 3.5级的lib,我尝试写一些自动化的测试,但运行在溶液中的任何测试时,我发现了以下错误:

I've got a .NET 3.5 class lib that I am trying to write some automated tests for but I'm getting the following error when running any tests in the solution:

测试方法Common.Tests.CommonTests.TestMethod1抛出异常信息:System.IO.FileNotFoundException:无法加载文件或程序集Library.Common,版本= 0.0.1.22004,文化= EN-AU,公钥=空'或者一个它的依赖。系统无法找到文件specified.WRN:集绑定日志记录被关闭

Test method Common.Tests.CommonTests.TestMethod1 threw exception: System.IO.FileNotFoundException: Could not load file or assembly 'Library.Common, Version=0.0.1.22004, Culture=en-AU, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.WRN: Assembly binding logging is turned OFF.

要启用程序集绑定失败日志记录,请将注册表值[HKLM \软件\微软\融合!EnableLog](DWORD)设置为1。

To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.

注:有一些与程序集绑定失败日志记录关联的性能损失。

Note: There is some performance penalty associated with assembly bind failure logging.

要关闭此功能,删除注册表值[HKLM \软件\微软\融合!EnableLog]。

To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

我是相当新的单元测试,所以我很为难。

I'm fairly new to unit testing so I'm stumped.

我compaired的lib和测试项目,唯一的区别之间的引用是测试项目引用MS单元测试的DLL。

I've compaired the references between the lib and the tests project and the only difference is that the tests project references the MS unit test DLL.

修改,以澄清

我使用的测试创建向导从我的'Library.Common项目中,以便测试项目有参考Library.Common项目。我已经清理并构建的解决方案也是如此,这不是问题。

I used the test creation wizard from within my 'Library.Common' project so the test project has the reference to the Library.Common project. I've cleaned and built the solution too, that's not the problem.

Library.Common.dll也就是在我的测试项目输出的bin \ Debug文件夹。

Library.Common.dll is also in the bin\Debug folder of my test project output.

推荐答案

发现的问题,我已经设置的 AssemblyCultureAttribute 的在我的Library.Common项目AssemblyInfo.cs文件。一旦删除它的测试运行。

Found the problem, I had set the AssemblyCultureAttribute in the AssemblyInfo.cs file in my Library.Common project. Once removing it the tests run.

现在真正了解如何使用这个属性!

Now to actually learn how to use that attribute!

这篇关于微软单元测试失败,无法加载DLL测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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