【问题标题】:Portable libraries with type providers具有类型提供程序的可移植库
【发布时间】:2012-04-09 20:40:50
【问题描述】:

据我了解,F# 类型提供程序始终是一个不可移植的类库(例如,它将使用在 WinRT 中不可用的 Reflection.Emit)。要在我的 F# 类库中使用它,我需要添加对类型提供程序 DLL 的引用,因此该库必须是不可移植的才能编译。

在这种情况下,我很乐意将其分成一个可移植程序集和一个使用类型提供程序的程序集。我可以编译它的唯一方法是向我的 C# 应用程序项目 (.NET 4.5) 添加对 Fsharp.Core 的引用 - 但在运行时 FSharp.Core 的版本之间仍然存在冲突。

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

我可以解决冲突吗?是我错误地使用了类型提供程序,还是目前还无法解决?

【问题讨论】:

    标签: f# type-providers portable-class-library


    【解决方案1】:

    您需要在 app.config 文件中进行绑定重定向。如果您创建一个以 4.5 为目标的新 F# 项目,它将具有

    <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
          <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
          <bindingRedirect oldVersion="2.3.5.0" newVersion="4.3.0.0"/>
        </dependentAssembly>
      </assemblyBinding>
    </runtime>
    

    在 app.config 中。您需要将其添加到最终使用的 exe 项目(例如 C# 项目)的 app.config 中,以便例如如果您在桌面上运行它,它会将便携式 FSharp.Core (2.3.5.0) 解析为桌面版 (4.3.0.0)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-13
      相关资源
      最近更新 更多