Can't load FSharp.Core version 4.0.0 in infer.net fun // hard link dependency in a dll ?
Asked Answered
R

2

3

I am trying Infer.Net (An F# Library for Probabilistic Programming) And running the examples in VS11 Beta lead to the error :

Could not load file or assembly 'FSharp.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

If I open the dlls used the infer.net samples in Reflector, one, probcomp.dll, says it can not find automatically "FSharp.Core, Version=4.0.0.0"and that I need to select the location by hand.

Are the two things linked ? Is it possible that probcomp.dll has been compiled with a 'fixed path' reference and that now it is not the same on my machine ?

PS : of course fsharp projects from scratch are working fine..

PS2 : The dll under reference in visual studio do not show any sign that they are not found. And I can open them in the object browser.

UPDATE

The error happens tight at start of the program, there is no time to see anything. Yet, it happens INSIDE the program : If the following line is not called

let coinsD = inferExpr <@ coins @> 

Then the errors does not happen. With it, the following error is raised, in a different example Unsurprisingly, it is from the dll whose behaviour was strange in reflector.

Could not load file or assembly 'FSharp.Core, Version=4.0.0.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)

The signature of the said function is quite strange in the object browser :

public static IDistribution<b>inferExpr<b>(**unknown-type e**)

YET, in reflector after I told him where to find Fsharp 4.0.0 upon opening the dll, it has the signature

public static IDistribution<b> inferExpr<b>(FSharpExpr<b> e);

This dll must have some kind of strange hard link dependencies, and reflector is smarter (or not..) than VS to figure it out.

To make a good from a bad, if you have any idea of what could have happened in this dll, this could be an occasion to learn.

Rex answered 10/3, 2012 at 12:27 Comment(9)
I'm able to run that example in VS11 targeting .NET 4.0 and using FSharp.Core 4.0.0.0. I encounter an error when targeting .NET 4.5 and changing FSharp.Core to 4.3.0.0 version. Could you observe the same behaviour?Goneness
trying to re-reproduce. you see the complete type in the object browser for Fsharp.Top.inferExpr ?Rex
after creating a new consoleapp, removing the binding that comes automatically <bindingRedirect oldVersion="2.3.5.0" newVersion="4.3.0.0"/>, adding the infer.net libraries, copying the exemple code using inferEXP, the error message is about ProbComp not loading because it can find a reference. which makes sense as it linked to fsharp 4.0.0.0Rex
I did not realize that in the folder Fsharp v4.0 you actually have v4.3.0.0 which, unlike framework 4 and 4.5, is not a drop in replacement. I will scout for the 4.0.0.0 fsharp dll it must be that.Rex
after installing the F# 2.0 redistributable package, the types are showing in the object browser for ProbComp.dll, and the assembly works...Rex
of interest is that the FSharp 4.0.0.0 dll are actually in the F#2.0 langage version, runtime v4.0. The Fsharp 4.3.0.0 dll is actually a F#3.0 langage version, runtime, errr v4.0 . there are some other v2.0 runtime version for each langage version but I feel a headache coming..Rex
Let's take it this way: FSharp.Core 4.0.0.0 -> .NET 4.0/F# 2.0, FSharp.Core 2.0.0.0 -> .NET under 4.0 /F# 2.0, FSharp.Core 4.3.0.0 -> .NET 4.5/F# 3.0 and FSharp.Core 2.3.0.0 -> .NET under 4.5/F# 3.0. BTW, I have updated my answer.Goneness
not too shabby. did not know all that. gracias.Rex
I keep coming back to your matrix, pad. what a beast !Rex
G
3

I'm able to run that example in VS11 targeting .NET 4.0 and using FSharp.Core 4.0.0.0. I encounter an error when targeting .NET 4.5 and changing FSharp.Core to 4.3.0.0 version.

So the problem is not hard link dependencies between dlls. Changing Target Framework in Project Properties to .NET 4.0 and carefully adding FSharp.Core 4.0.0.0 in Reference dialog (noticing there are various versions of FSharp.Core available) would solve the problem.

In your case, since F# 2.0 runtime is missing, installing it first before doing the above step.

Goneness answered 10/3, 2012 at 12:50 Comment(2)
Hi pad, I very vaguely remember an option in devenv.exe.config to allow foreign dll to be loaded, which it can't by default I think. since my install is new that might be it too. I will check what you say, but if you remember the config stuff I talk about that might be it too.Rex
is it possible that the dll is compiled against a specific dll and not a GAC dll ? dont know if that makes any sense..Rex
S
8

An app.config file with

<?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="4.0.0.0" newVersion="4.3.0.0"/>
        </dependentAssembly>
      </assemblyBinding>
    </runtime>
</configuration>

will fix things right up.

Sallie answered 10/3, 2012 at 17:42 Comment(3)
I added that to fsi.exe.config on another install without 2.0 redist package, to use FsEye.fsx which requires 4.0.0.0. Is that always working ? All apps working with 4.0.0.0 are supposed to work with 4.3.0.0 ?Rex
FSCore 4.3.0.0 has everything in 4.0.0.0 and more, so it should always work to redirect to the higher version, yes.Sallie
In our case (we had the same error), we solved the issue by adding a reference to FSharp.Core to a project that did not directly use FSharp.Core but had a reference to another project in the same solution that did. Kind of a cryptic error indeed. But that's another thing to check out. Our project that failed was not an app project and therefore we could not use binding redirects even if we wanted to.Tinsmith
G
3

I'm able to run that example in VS11 targeting .NET 4.0 and using FSharp.Core 4.0.0.0. I encounter an error when targeting .NET 4.5 and changing FSharp.Core to 4.3.0.0 version.

So the problem is not hard link dependencies between dlls. Changing Target Framework in Project Properties to .NET 4.0 and carefully adding FSharp.Core 4.0.0.0 in Reference dialog (noticing there are various versions of FSharp.Core available) would solve the problem.

In your case, since F# 2.0 runtime is missing, installing it first before doing the above step.

Goneness answered 10/3, 2012 at 12:50 Comment(2)
Hi pad, I very vaguely remember an option in devenv.exe.config to allow foreign dll to be loaded, which it can't by default I think. since my install is new that might be it too. I will check what you say, but if you remember the config stuff I talk about that might be it too.Rex
is it possible that the dll is compiled against a specific dll and not a GAC dll ? dont know if that makes any sense..Rex

© 2022 - 2024 — McMap. All rights reserved.