1

I use NSubstitute v1.7.1.0 and AutoFixture.AutoNSubstitute v3.16.5. Obviously AutoFixture was compiled against an older version of NSubsitute.

In a test I get the exception:

System.IO.FileNotFoundException : Could not load file or assembly 'NSubstitute,
Version=1.4.3.0, Culture=neutral, PublicKeyToken=92dd2e9066daa5ca' or one of its
dependencies. The system cannot find the file specified.

So I added a binding redirect to my test project (as suggested here):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="NSubstitute" publicKeyToken="92dd2e9066daa5ca" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.7.1.0" newVersion="1.7.1.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

Still getting the exception. What am I doing wrong?


EDIT : The problem disappears when I use AutoFixture for creating an instance of a class instead of an interface (myFixture.Create<MyClass>() instead of myFixture.Create<MyInterface>()).

EagleBeak
  • 6,939
  • 8
  • 31
  • 47
  • 3
    Are the DLLs in the dir? Is the AppDomain being reloaded when you put the binding redirect into your .config file (i.e. is your test runner process caching things without picking up the new config)? What does the version info say. It makes sense for it to go away when you create a concrete class as that takes the need for mocking out of the picture. – Ruben Bartelink Feb 25 '14 at 21:17
  • Can you share some more of the .config file in which you've put the `assemblyBinding`. I sometimes accidentally put it in the wrong parent element, and then it doesn't work... – Mark Seemann Feb 25 '14 at 22:08
  • @MarkSeemann: This IS my entire config file. I edited it above to clarify. – EagleBeak Feb 26 '14 at 07:07
  • @RubenBartelink: Thanks for pointing my to the test runner. That was it of course! – EagleBeak Feb 26 '14 at 07:25

1 Answers1

2

The problem was caused by ReSharper's test runner. It went away after increasing ReSharper's new "Run up to X assemblies in parallel" option as described in this answer.

Community
  • 1
  • 1
EagleBeak
  • 6,939
  • 8
  • 31
  • 47