.net - 无法在 infer.net fun 中加载 FSharp.Core 版本 4.0.0//dll 中的硬链接(hard link)依赖项?

标签 .net dll .net-4.0 f# reflector

我正在尝试 Infer.Net (An F# Library for Probabilistic Programming)
在 VS11 Beta 中运行示例会导致错误:

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.



如果我在 Reflector 中打开使用 infer.net 示例的 dll,其中一个 probcomp.dll 说它无法自动找到“FSharp.Core,Version=4.0.0.0”,我需要手动选择位置。

这两件事有联系吗?
probcomp.dll 是否可能已使用“固定路径”引用进行编译,而现在它在我的机器上不一样了?

PS:当然,从头开始的 fsharp 项目运行良好..

PS2:Visual Studio 中引用的 dll 没有显示任何找不到它们的迹象。我可以在对象浏览器中打开它们。

更新

错误发生在程序启动时,没有时间看到任何东西。
然而,它发生在程序内部:如果没有调用以下行
let coinsD = inferExpr <@ coins @> 

然后错误不会发生。
有了它,在另一个示例中会引发以下错误
不出所料,它来自反射器中行为奇怪的 dll。

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)



该函数的签名在对象浏览器中很奇怪:
public static IDistribution<b>inferExpr<b>(**unknown-type e**)

然而,在反射器中 之后 我告诉他在打开 dll 时在哪里可以找到 Fsharp 4.0.0,它有签名
public static IDistribution<b> inferExpr<b>(FSharpExpr<b> e);

这个 dll 必须有某种奇怪的硬链接(hard link)依赖关系,并且反射器比 VS 更聪明(或不......)来解决它。

为了从坏中变好,如果您对这个 dll 中可能发生的事情有任何想法,这可能是一个学习的机会。

最佳答案

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

会马上解决问题。

关于.net - 无法在 infer.net fun 中加载 FSharp.Core 版本 4.0.0//dll 中的硬链接(hard link)依赖项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9646404/

相关文章:

c# - 如何以编程方式选择 WPF TreeView 中的项目?

.net - 云计算-Azure

c# - 在没有安装 Visual Studio 的情况下构建 VDProj

c# - 在 C# 中包装 C++ 类 DLL

c# - 如何在 Visual Studio 2010 中将自己的扩展添加到 html/aspx 代码编辑器的上下文菜单中?

c# - 使用 NHibernate 的深层复制实体

c++ - 'HMODULE LoadLibraryA(LPCSTR )': cannot convert argument 1 from ' const _Elem *' to ' LPCSTR'

c++ DLL\static 库名称问题

c# - 遍历一个类的属性

c# - 将 LINQ Except() 与两个不同类型的集合一起使用