简体   繁体   English

Nunit System.BadImageFormatException

[英]Nunit System.BadImageFormatException

I'm having some trouble running my tests from command line.我在从命令行运行测试时遇到了一些问题。 I have a separate project for the tests and usually using Rider where the tests run flawlessly.我有一个单独的测试项目,并且通常使用 Rider,在那里测试可以完美运行。 However, I want to run them in a CI environment and therefore need to be able to run them form command line.但是,我想在 CI 环境中运行它们,因此需要能够从命令行运行它们。

I'm trying to run Projectname>"C:\\Program Files (x86)\\NUnit.org\\nunit-console\\nunit3-console.exe" Test\\Test.csproj NUnit Console Runner 3.4.0 Copyright (C) 2016 Charlie Poole我正在尝试运行 Projectname>"C:\\Program Files (x86)\\NUnit.org\\nunit-console\\nunit3-console.exe" Test\\Test.csproj NUnit Console Runner 3.4.0 版权所有 (C) 2016 Charlie Poole

Runtime Environment
   OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1
  CLR Version: 4.0.30319.42000

Test Files
    Test\Test.csproj

Errors and Failures

1) Error : Test.MVCmodel.CoilClassTest.CoilCreateEmptyIdTest
System.BadImageFormatException : Could not load file or assembly 'UserInterface, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
   at Test.MVCmodel.CoilClassTest.CoilCreateEmptyIdTest()

The same thing happens when running "C:\\Program Files (x86)\\NUnit.org\\nunit-console\\nunit3-console.exe" Test\\bin\\Debug\\Test.dll运行“C:\\Program Files (x86)\\NUnit.org\\nunit-console\\nunit3-console.exe” Test\\bin\\Debug\\Test.dll 时会发生同样的事情

The Test Project is located inside the MainProject: Projectname\\Projectname.csproj and Projectname\\Test\\Test.csproj测试项目位于 MainProject 中:Projectname\\Projectname.csproj 和 Projectname\\Test\\Test.csproj

And yes, I have found quite a few posts similar on Stackoverflow, but I found no applicable solution.是的,我在 Stackoverflow 上发现了很多类似的帖子,但我没有找到适用的解决方案。

This solved the problem for me.这为我解决了这个问题。 Under build settings change the platform target to x86在构建设置下,将平台目标更改为 x86

在此处输入图片说明

This of course is assuming that UserInterface exists and runs well outside of the CLI environment (like in visual studio)这当然是假设 UserInterface 存在并且在 CLI 环境之外运行良好(例如在 Visual Studio 中)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM