我得到System.BadImageFormatException:运行单元测试的操作系统无法运行异常单元测试、异常、操作系统、System

2023-09-04 06:07:41 作者:Night丶御风

我工作的一个WinForms项目。目前,我面临着一个问题,即在运行一些测试用例抛出

I am working on a Winforms project. Currently I am facing a problem that running some of the test cases throw

    System.BadImageFormatException : The operating system cannot run . 
(Exception from HRESULT: 0x800700B6)

例外。仅发生这种情况,如果我通过NUnit的运行测试。但是,如果我运行通过code中的应用程序,它工作正常。

exception. This happens only if I run tests through NUnit. However, if I run the application through the code, it works fine.

远程处理中正在使用的应用程序。可以说是一个问题?

Remoting is being used in the application. Can that be an issue?

推荐答案

确认双方NUNIT和你的code编译到同一个平台 - x86或x64。最简单的事情,该平台设置为任何CPU 在您code。

Make sure both NUNIT and your code are compiled to the same platform - x86 or x64. The easiest thing to set the platform to 'Any CPU' on your code.