2
votes

I have the following error when attempting to run a test:

{System.IO.FileLoadException: Could not load file or assembly 'FSharp.Core, Version=3.3.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) File name: 'FSharp.Core, Version=3.3.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' at Register.RegisterResponse.__DebugDisplay()

Tests.dll

FSharp.Core: 3.1.2.5

Target F# runtime: 4.3.1.0

Target Framework: 4.6

Output type: Class Library

ManageAccount.dll

FSharp.Core: 3.1.2.5

Target F# runtime: 3.3.1.0

Target Framework: .NET Portable Subset (.Net Framework 4.5, ASP.Net Core 1.0, Windows 8)

Output type: Class Library

I then added the following app config to my test project:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a"
                          culture="neutral"/>
        <bindingRedirect oldVersion="3.1.2.5" newVersion="3.3.1.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

If I do need an app config, what value should my bindingRedirect be set to?

2

2 Answers

5
votes

Try <bindingRedirect oldVersion="0.0.0.0-999.999.999.999" newVersion="3.3.1.0" />. That's what most F# projects seem to be doing for FSharp.Core. (Or newVersion="4.3.1.0", or even newVersion="4.4.0.0" if you upgrade to a newer FSharp.Core).

1
votes

You should use the newest version (4.3.1.0 in this case) in bindingRedirect/newVersion, otherwise, you will probably get errors from code in Tests.dll assembly which relies on the newer version.

Alternatively you can update the reference in one of the assemblies (downgrade Tests.dll or upgrade ManageAccount.dll) so that they both use the same version.