I am getting System.BadImageFormatException : The operating system cannot run exception while running unit tests

醉酒当歌 提交于 2019-12-23 03:58:05

问题


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)

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?


回答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.




回答2:


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>


来源:https://stackoverflow.com/questions/10926227/i-am-getting-system-badimageformatexception-the-operating-system-cannot-run-ex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!