简体   繁体   English

F#-Array.Parallel模块不可访问

[英]F# - Array.Parallel module not accessible

I can access the Array.Parallel module in F# Interactive but not when compiling. 我可以在F#Interactive中访问Array.Parallel模块,但在编译时不能访问。 What might be wrong ? 可能是什么问题? (VS 2010) (VS 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

This code compiles fine in FSI but when part of a project fails: 该代码在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.

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

The Parallel module is implemented via System.Threading.Tasks , which were not introduced until .NET 4.0. Parallel模块通过System.Threading.Tasks实现,直到.NET 4.0才引入。 Thus the Parallel module doesn't exist on Array in the .NET 2.0 version of FSharp.Core.dll. 因此, Parallel模块在FSharp.Core.dll的.NET 2.0版本中的Array上不存在。 If you re-target to 4.0 it will work. 如果您将目标重新定位到4.0,它将起作用。

It works in FSI because FSI runs in a .NET 4 environment. 它在FSI中工作,因为FSI在.NET 4环境中运行。

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

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