Konstantin Konstantin -4 years ago 1289
C# Question

NUnit failed to load DLL

I am getting the following error message when trying to run unit tests in Visual Studio:

NUnit failed to load w:\Repos\trading.tools\Trading.Tools.Test\bin\x64\Debug\Trading.Tools.Test.dll

I am using

  • Visual Studio Community 2013

  • NUnit Adapter

  • NUnit 3.4.1

The weird thing is, that I have another project which is set up the same way as this one and it works just fine.

I also downloaded NUnit 3.4.1 and installed it. When I run

nunit3-console.exe Trading.Tools.Test.dll

everything works just fine.
Any ideas what I can do?

Many thanks

Edit #1

Here is the full console output from Visual Studio when trying to run all test.

Test run will use DLL(s) built for framework Framework45 and platform X86. Following DLL(s) will not be part of run:
Trading.Tools.Test.dll, Trading.Tools.dll are built for Framework Framework45 and Platform X64.
Go to http://go.microsoft.com/fwlink/?LinkID=236877&clcid=0x409 for more details on managing these settings.
NUnit Adapter Test discovery starting
NUnit failed to load w:\Repos\trading.tools\Trading.Tools.Test\bin\x64\Debug\Trading.Tools.Test.dll
Assembly contains no NUnit 3.0 tests: w:\Repos\trading.tools\Trading.Tools\bin\x64\Debug\Trading.Tools.dll
NUnit Adapter Test discovery complete

As you can see it is very obvious that NUnit expects a x86 build, but I build for a x64 platform. And again, my x64 build works just fine if I execute it using

What I see in the
file is this:

<Reference Include="nunit.framework, Version=, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">

The weird thing here is that it specifies using
but referencing a 3.4.1 dll.

So the next question from this point is how can I make NUnit execute my x64 build? Any ideas?

Answer Source

I had a similar issue, the key is the fact that it is the Test Runner in Visual Studio that is stating that only x86 assemblies will be tested. I am assuming from this that it then forces the use of the x86 NUnit runner. To change this (in VS2015 at least), go to Test > Test Settings > Default Processor Archiatecture > X64.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download