简体   繁体   中英

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. However, I want to run them in a CI environment and therefore need to be able to run them form command line.

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

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

The Test Project is located inside the MainProject: Projectname\\Projectname.csproj and Projectname\\Test\\Test.csproj

And yes, I have found quite a few posts similar on Stackoverflow, but I found no applicable solution.

This solved the problem for me. Under build settings change the platform target to x86

在此处输入图片说明

This of course is assuming that UserInterface exists and runs well outside of the CLI environment (like in visual studio)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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