Chris Schmitz
Chris Schmitz

Reputation: 390

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 "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:

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):

Upvotes: 1

Views: 396

Answers (1)

Chris Schmitz
Chris Schmitz

Reputation: 390

After some additional research i found a similar post in the ReSharper Community, that indicates that ReSharper is configured to create and use a testsettings file in MetaData of the application per default, which is not configured to use the x64 architecture. I had to create a custom TestSettings file on my solution (which is placed under Solution Items), set it to force running in x64 and then edit the ReSharper setting to use this custom TestSettings file instead of the default one. I still do not know why ReSharper isn't using the default processor architecture specified for MSTest and also ignoring the settings i specified explicitly in the ReSharper settings.

But anyway it's working now.

Upvotes: 1

Related Questions