【发布时间】:2016-02-04 13:45:03
【问题描述】:
我编写了一个单元测试,它使用 testsettings 文件在 OUT 文件夹中部署一些引用的 dll。我使用这个命令运行我的单元测试。
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\MSTest.exe"
"/testcontainer:C:\Unittests\unit_test.dll"
"/runconfig:C:\Unittests\unit_test_settings.testsettings"
"/resultsfile:C:\Unittests\unit_test_results.trx"
我的单元测试中的一些测试运行良好,但有些测试失败并出现以下错误。
对象初始化失败 (ISupportInitialize.EndInit)。无法找到或无法加载名为“some_referenced_dll.resources.dll, PublicKeyToken=”的备用文化“en”的附属程序集。这通常是设置问题。请考虑重新安装或修复应用程序。
System.Resources.MissingSatelliteAssemblyException:卫星程序集名为...
为了解决这个问题,我在 testsettings 文件中添加了 some_referenced_dll.resouce.dll 作为部署项,但这并没有帮助。
我可以看到 dll 被复制到 OUT 文件夹中。
在我添加 some_referenced_dll.dll 作为对项目的引用后,测试在 VS 2012 中运行良好。
更多信息:
有些测试直接使用其他 dll 作为参考(比如 ref_dll_2.dll)并通过。这个 ref_dll_2.dll 也在 OUT 文件夹中。
我遇到了一个 dll (some_referenced_dll.resouce.dll) 的问题,该问题没有从我的测试中直接引用。我的单元测试调用了一些开发代码,这些代码又尝试初始化一个失败的类。
强制加载 dll 是否有意义?有没有办法做到这一点?
【问题讨论】:
标签: c# unit-testing mstest