簡體   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