简体   繁体   中英

Binding redirect not working with multiple test projects in ReSharper's NUnit test runner

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>() ).

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM