Question

I am working on a Selenium webdriver based C# NUnit project, where I have several tests which take screenshots and record video of each test scenario using Microsoft.Expression.Encoder.dll. I'm planning to run these tests from command line using the below code sample.

nunit-console /run:MyProject.Tests.SampleTest MyProject.dll

As my project is built on .NET Framework 4.0, I did updated the config file for nunit to use framework 4.0 using the below line of setting.

<supportedRuntime version="v4.0.30319" />

My issue is, when i try to run a test, i get below error. I tried building the project in x86 and x64 mode, but the issue remains.

Errors and Failures: 1) Test Error : MyProject.Tests.SampleTest System.BadImageFormatException : Could not load file or assembly 'Microsoft.Expression.Encoder, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. An attempt was made to load a program with an incorrect format.

I also tried to run a simple test, which runs fine from command line.

Was it helpful?

Solution

I figured out the solution. As I am using Microsoft.Expression.Encoder DLL in my project to video record a test, this DLL is compiled as x86. Thus I can keep my selenium C# project in Any CPU mode and use the below command to execute tests.

nunit-console-x86 /run:MyProject.Tests.SampleTest MyProject.dll

Nunit folder has two "nunit-console" exes (nunit-console.exe and nunit-console-x86.exe)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top