Search code examples
visual-studiocntk

Assembly loading fails with CNTK EvalWrapper


I have a .NET assembly with some tests that references CNTK's EvalWrapper.dll. The CNTK build is targeting x64, the .NET test assembly has build target AnyCPU. I have ensured that all required DLLs are available in the build output directory, see this SO question here. I've chosen x64 in VS Test Settings / Processor Architecture.

My tests ran fine for a while, but now started to fail with an assembly loading error, BadImageFormatException when loading EvalWrapper.dll. Inspecting the loading errors with the Fusion Log Viewer also did not reveal anything beyond the incorrect format:

The operation failed.
Bind result: hr = 0x8007000b. An attempt was made to load a program with an incorrect format.
Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\te.processhost.managed.exe
--- A detailed error log follows. 
=== Pre-bind state information ===
LOG: DisplayName = EvalWrapper, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null

There is nothing I've changed in my project setup. What could have changed silently that makes my tests now all fail?


Solution

  • I guess the culprit was a 32bit test execution engine that had been still running in the background - even though I had made sure that "Test Settings / Keep Test Execution Engine Running" was not ticked. I had a moment yesterday where I noticed that VS had "forgotten" my choice of processor architecture, and it was reset to 32 bit. I changed it back to 64 bit - with hindsight, I guess that's where the problem started.

    VS silently changing the processor architecture for tests is something I had noticed previously in other projects, too.

    Closing and re-opening VS did the trick, all tests now pass again. Alternatively, I could probably have looked for all test execution engine processes that were running, and kill those.