Question

I added an existing project to my solution. When I run all unit tests with MSTest runner, I get the following error on a couple of tests:

Message: Test method soandso threw exception: System.IO.FileLoadException: Could not load file or assembly 'log4net, Version 1.2.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a' or one of it's dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT:0x80131040)

I know others have had the same problem and there is other questions and answers about this topic. But I tried many things, but nothing helped. The version of log4net we use is 1.2.13.0.

I checked with FUSLOGVW.exe for binding errors. The log4net shows up with the added assembly and some Unknown assembly. The reference of log4net in the assembly shows version 1.2.13.0 which was added with NuGet. So it is probably a dependent assembly that is causing all this trouble. I tried changing log4net back to version 1.2.12.0, but I still get the same error message.

When I run all the tests with MSTest testrunner, these errors show up. When I only run the failed tests, they pass. When I run them individually, they also pass. I tried binding redirection, but I did it for the assembly that is tested not the testing assembly. I did not know how to do that for a test assembly - there is no config. When I run the tests with Resharper test runner they also pass (but other tests fail). The TFS Build server runs the MSTest-runner, therefore I need to get it working with MSTest.

Does anyone know how I can get this resolved?

Was it helpful?

Solution

The culprit was found. Like I was suspecting, a dependent assembly was referencing log4net 1.2.12.0. The tool used to find out was dotPeek. Luckily we do have the source code for the dependent assembly and we can change it to reference the latest log4net. This solves this issue.

So if anyone has a similar problem, use dotPeek or a similar tool to go through the dependent assemblies to find out what versions of assemblies it is referencing.

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