mercredi 3 août 2016

ReSharper Testrunner fails on x64 with BadImageFormatException

I have a Visual Studio solution where i use MSTest for my Unit-Testing, and would like to use the ReSharper Testrunner as i think the Visual Studio Test Explorer is really painful to work with. My whole solution is built for x64, because i have some dependent assemblies that are specifically compiled for x64 and not available for x86.

My unit-tests run fine in the VS Test Explorer, but they fail in the ReSharper Testrunner.

The following exception is being thrown, right before it hits the first line of the unit-test:

Unable to get type xxx.xxx.xxx. Error: System.BadImageFormatException: Die Datei oder Assembly "http://file/D:\path\to\unit\test\project\bin\Debug\xxx.xxx.xxx.dll" oder eine Abhängigkeit davon wurde nicht gefunden. Es wurde versucht, eine Datei mit einem falschen Format zu laden.

Sorry for the exception being in german. It's just a 'typical' BadImageFormatException where xxx.xxx.xxx is the type of my unit-test project. The Stacktrace indicates that the exception is being thrown from

Microsoft.VisualStudio.TestPlatform.MSTestFramework.TypeCache.LoadType(String typeName, String assemblyName)

I know that there are already many similar questions on stackoverflow, but i already tried every possible solution i found (without any effect), and therefore i assume my problem lies somewhere else.

What i tried and checked so far:

  • I double checked every project in my solutions to be compiled to x64 (even in release mode) -- everyhting seems fine
  • Default processor architecture for MSTest is explicitly set to x64 (Probably that's why it's working with the built-in Test Explorer)
  • Though it should be decided based on the platform of the project, i explicitly set the platform in ReSharper Testrunner to x64
  • I even modified the Unit Testing settings for ReSharper to force the execution of the unit-tests in a 64-bit process
  • Disabled Shadow-Copy of the assemblies in ReSharper settings (Just because i'm pretty frustrated right now, and switched to trial & error mode just before i started creating this question)

It's irritating that the tests run fine with Test Explorer, but not with ReSharper, though both have been set to x64. Am i missing a specific setting i need to modify? Or are they some known problems when using ReSharper in combination with MSTest? I might also consider using nUnit instead, but i'd need to modify all tests, so preferably i'd stay with MSTest.


Additionaly some information about versions and stuff (don't know if it might be helpful):

  • Visual Studio Premium 2013 v12.0.30110.00 Update 1
  • .NET Framework 4.5 on every project in the solution
  • ReSharper 8.2 C# Edition, Build 8.2.0.2160

Aucun commentaire:

Enregistrer un commentaire