I am working on a Winforms project. Currently I am facing a problem that running some of the test cases throw
我正在开发一个Winforms项目。目前我遇到一个问题,运行一些测试用例抛出
System.BadImageFormatException : The operating system cannot run .
(Exception from HRESULT: 0x800700B6)
exception. This happens only if I run tests through NUnit. However, if I run the application through the code, it works fine.
例外。只有当我通过NUnit运行测试时才会发生这种情况。但是,如果我通过代码运行应用程序,它可以正常工作。
Remoting is being used in the application. Can that be an issue?
Remoting正在申请中使用。这可能是个问题吗?
2 个解决方案
#1
1
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.
确保将NUNIT和代码编译到同一平台 - x86或x64。将平台设置为代码上的“任何CPU”最简单的方法。
#2
0
I had similar issue but in my case configuration file for application helped . This file contained following entries:
我有类似的问题,但在我的情况下,应用程序的配置文件帮助。该文件包含以下条目:
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<requiredRuntime version="v4.0" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
</configuration>
#1
1
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.
确保将NUNIT和代码编译到同一平台 - x86或x64。将平台设置为代码上的“任何CPU”最简单的方法。
#2
0
I had similar issue but in my case configuration file for application helped . This file contained following entries:
我有类似的问题,但在我的情况下,应用程序的配置文件帮助。该文件包含以下条目:
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<requiredRuntime version="v4.0" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
</configuration>