【发布时间】:2026-02-12 18:15:02
【问题描述】:
我有一个 C++/CLI DLL,它使用了一些 C++ DLL(都是为 32 位构建的)。我想使用 NUUnit 2.5.8.10295 在 C# DLL 中对其进行测试(更改为 2.6.4 并没有改变结果)
我使用了一个批处理文件,最终扩展为:
nunit-console-x86.exe "someUnitTests.dll" /framework=4.0.30319 /xml=NUnitResult_someUnitTests.xml
使用此命令,测试在我的开发 PC(64 位 Win 10 Enterprise Visual Studio 2013)上运行良好。从 Visual Studio Professional 2013 启动 nunit-console-x86.exe 并将工作目录设置为两个 DLL 的输出文件夹时,它也可以正常工作。
在构建服务器(在 Windows Server 2012 R2 上运行的 Jenkins)上执行时,测试失败并显示以下消息:
SetUp : System.IO.FileLoadException : Could not load file or assembly 'some.DLL' or one of its dependencies. A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)
除了使用 VS 2013 Express 的 buildserver 之外,我尝试比较两台机器上已安装的框架和运行时(看不到明显的大差异)。我还尝试了 SysInternals ProcessMonitor,但没有成功。我不明白依赖行者的输出。
对使用的技术或工具有任何提示吗?
更新: 如果我添加 /noshadow,它也不再在我的开发 PC 上运行。在 Visual Studio 中,然后 nunit-console-x86 崩溃,而在命令行上我得到与构建服务器上相同的消息。虽然在有或没有 /noshadow 的情况下运行都没有区别
在没有任何 Visual Studio 但使用 vc_redist 2013 的 Windows 7 上仔细查看测试 PC:启用卷影复制(= 没有 /noshadow)我明白了:
SetUp : System.IO.FileNotFoundException : Could not load file or assembly 'some.DLL' or one of its dependencies. The specified module could not be found.
使用 /noshadow 错误会变成 BadImageFormatException
【问题讨论】:
标签: c# c++ nunit command-line-interface badimageformatexception