Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 我正在获取System.BadImageFormatException:运行单元测试时操作系统无法运行异常_C#_.net_Nunit_Badimageformatexception - Fatal编程技术网

C# 我正在获取System.BadImageFormatException:运行单元测试时操作系统无法运行异常

C# 我正在获取System.BadImageFormatException:运行单元测试时操作系统无法运行异常,c#,.net,nunit,badimageformatexception,C#,.net,Nunit,Badimageformatexception,我正在做一个Winforms项目。目前我面临一个问题,运行一些测试用例会抛出 System.BadImageFormatException : The operating system cannot run . (Exception from HRESULT: 0x800700B6) 例外。只有通过NUnit运行测试时才会发生这种情况。但是,如果我通过代码运行应用程序,它可以正常工作 应用程序中正在使用远程处理。这会成为一个问题吗 确保NUNIT和您的代码都编译到同一平台—x86或x

我正在做一个Winforms项目。目前我面临一个问题,运行一些测试用例会抛出

    System.BadImageFormatException : The operating system cannot run . 
(Exception from HRESULT: 0x800700B6)
例外。只有通过NUnit运行测试时才会发生这种情况。但是,如果我通过代码运行应用程序,它可以正常工作


应用程序中正在使用远程处理。这会成为一个问题吗

确保NUNIT和您的代码都编译到同一平台—x86或x64。将平台设置为“任意CPU”最简单的方法
在您的代码上。

确保NUNIT和您的代码都编译到同一个平台—x86或x64。将平台设置为“任意CPU”最简单的方法
关于您的代码。

我也有类似的问题,但在我的情况下,应用程序的配置文件有帮助。此文件包含以下条目:

<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <requiredRuntime version="v4.0" />
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
    </startup>
</configuration>

我也有类似的问题,但在我的案例中,应用程序的配置文件有帮助。此文件包含以下条目:

<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <requiredRuntime version="v4.0" />
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
    </startup>
</configuration>


它被称为“AnyCPU”,而不是“两者”;我可以检查NUnit编译到哪个平台吗?只需将您的设置更改为“任意cpu”(谢谢@leppie),无论NUnit如何编译,它都应该工作。它已经是“任意cpu”。这是我的第一个预感。但它不起作用我在x86机器上工作。那么,改为x64有意义吗?它是一个名为“AnyCPU”而不是“两者”的处理器;我可以检查NUnit编译到哪个平台吗?只需将您的设置更改为“任意cpu”(谢谢@leppie),无论NUnit如何编译,它都应该工作。它已经是“任意cpu”。这是我的第一个预感。但它不起作用我在x86机器上工作。那么,改为x64有意义吗?