I've created a project in F# that targets F# 3.1 runtime (that is, FSharp.Core version 4.3.1). Then I've created a console C# application, added a project reference to my F# project, added a reference to FSharp.Core.dll 4.3.1.
Everything compiles without any errors or warnings, but the runtime throws this when I'm trying to use any type from F# project:
System.IO.FileLoadException : Could not load file or assembly 'FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.
Why does it searches for FSharp.Core 4.3.0 when all my projects reference 4.3.1? If I change all project references from 4.3.1 to 4.3.0 that everything will work fine, but what's up with version 4.3.1?
P.S. Both project target .NET 4.5.1. I am using Microsoft Visual Studio 2013
This is the wild guess but based on the exception you get it's likely that you have other FSharp assemblies inside your project.
So the error indicates that one of the dependencies you're using requires FSharp.Core 4.3.0.0
. Let's say your project references other FSharp dependencies like for example FSharp.Data 2.2.0.0
. Even, if you have added an explicit reference in your own project to FSharp.Core 4.3.1.0
this won't work becasue FSharp.Data 2.2.0.0
was built against FSharp.Core 4.3.0.0
. To fix that you need to add a bindingRedirect into your project configuration file app.config
:
<?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="0.0.0.0-4.3.1.0" newVersion="4.3.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
This should fix the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With