繁体   English   中英

引用 x64 dll 文件在 C# 中有效,但在 F# 中无效

[英]Referencing an x64 dll file works in C# but does not work in F#

我使用最新的 VS 2010 创建了两个全新的解决方案:

  • C# 控制台应用程序
  • F# 控制台应用

我引用了两个 x64 dll 文件: Kitware.VTK.dllKitware.mummy.Runtime.dll
(可以在这里下载: http://www.kitware.com/products/avdownload.php

C# VS 2010 在我using Kitware编写时找到了命名空间。
F# VS 2010 在我编写open Kitware时找不到命名空间。

x86 版本在 F# 中运行良好。 知道为什么会这样以及如何使 Kitware x64 在 F# 中工作吗?

这可能是由于这里描述的错误:

F# 项目引用在 Visual Studio 2010 中针对 x64 平台时不起作用

他们说它将在 VS 的下一个版本中修复。

好好的-h-

我想我可能有一个解决办法。 它需要手动编辑您的 fsproj 文件。

<PropertyGroup>项之后和第一个<Import>之前添加它。

  <PropertyGroup Condition="'$(Platform)' == 'x64'">
    <!--
    Assembly resolution using msbuild is broken for the x64 platform in F# 2.0.
    See https://connect.microsoft.com/VisualStudio/feedback/details/588317/f-project-references-not-working-when-targeting-x64-platform-in-visual-studio-2010
    We use simple resolution with a hard-coded list of paths to look for the dlls instead.
    -->
    <NoStdLib>true</NoStdLib>
    <OtherFlags>--simpleresolution</OtherFlags>
    <ReferencePath>C:\Windows\Microsoft.NET\Framework64\v3.5;C:\Windows\Microsoft.NET\Framework64\v2.0.50727</ReferencePath>
  </PropertyGroup>

请注意, OtherFlags已被覆盖,这对我来说没问题,因为它是空的。 如果使用它,您可能应该将 append 改为变量。 最好将Microsoft.Build.Tasks用于路径列表,而不是使用硬编码列表,但我无法让它工作。

F# 控制台应用程序默认针对 x86 而不是任何 CPU。 如果您没有更改它,那么 F# 项目将无法与 x64 库一起使用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM