1

我可以Array.Parallel在 F# Interactive 中访问该模块,但在编译时不能。可能有什么问题?(对比 2010 年)

namespace X  // not sent to interactive
open Microsoft.FSharp.Collections
module M = 
  let square  (a _[]) = Array.map          (fun a ->  a*a ) // OK        
  let squareP (a:_[]) = Array.Parallel.map (fun a ->  a*a ) // Error: "Parallel" not defined

此代码在 FSI 中编译得很好,但是当项目的一部分失败时:

------ Erstellen gestartet: Projekt: DELETE TEST, Konfiguration: Debug Any CPU ------ C:\Program Files (x86)\Microsoft F#\v4.0\fsc.exe -o:obj\Debug\DELETE_TEST.dll -g --debug:full --noframework --define:DEBUG --define:TRACE --doc:bin\Debug\DELETE_TEST.XML --optimize- --tailcalls- -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\2.0\Runtime\v2.0\FSharp.Core.dll" -r:C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll -r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" -r:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll --target:library --warn:3 --warnaserror:76 --vserrors --LCID:1031 --utf8output --fullpaths --flaterrors Module1.fs C:\work\Goswin\30_F#\16-135_LAD\DELETE TEST\Module1.fs(7,37): Fehler FS0039: Der Wert, Konstruktor, Namespace oder Typ "Parallel" ist nicht definiert.

4

1 回答 1

2

您的目标是 .NET 2.0:-r:"C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\2.0\Runtime\v2.0\FSharp.Core.dll"

Parallel模块是通过 实现System.Threading.Tasks的,直到 .NET 4.0 才引入。因此,该模块在 .NET 2.0 版本的 FSharp.Core.dllParallel中不存在。Array如果您重新定位到 4.0,它将起作用。

它适用于 FSI,因为 FSI 在 .NET 4 环境中运行。

于 2013-08-14T16:57:14.490 回答