运行F#中CoreCLR [英] Running F# in CoreCLR

查看:188
本文介绍了运行F#中CoreCLR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编译 CoreCLR CoreFX 这里描述。基本上是工作,我可以编译和运行C#代码瞄准CoreCLR。结果
下一步是尝试编译并运行F#代码。所以我加了
FSharp.Core 3.1.2.1 到项目并使用以下命令编译一个示例应用程序:

  FSC ^ 
--noframework ^
--targetprofile:磊科^
/ R: packages\System.Runtime.4.0.20-β-22703\lib\contract\System.Runtime.dll ^
/r:packages\System.Reflection.4.0.10-beta-22703\\ \\lib\contract\System.Reflection.dll ^
/r:packages\System.Collections.4.0.10-beta-22703\lib\contract\System.Collections.dll ^
/r:packages\System.Diagnostics.Debug.4.0.10-beta-22703\lib\contract\System.Diagnostics.Debug.dll ^
/r:packages\System.IO .FileSystem.4.0.0-β-22703\lib\contract\System.IO.FileSystem.dll ^
/r:packages\System.Linq.Expressions.4.0.10-beta-22703\\ \\lib\contract\System.Linq.Expressions.dll ^
/r:packages\System.Console.4.0.0-beta-22703\lib\contract\System.Console.dll ^
/r:packages\System.Runtime.Extensions.4.0.10-beta-22703\lib\contract\System.Runtime.Extensions.dll ^
/ R:packages\System .Runtime.InteropServices.4.0.20-β-22703\lib\contract\System.Runtime.InteropServices.dll ^
/r:packages\System.Text.Encoding.4.0.10-beta- 22703\lib\contract\System.Text.Encoding.dll ^
/r:packages\System.Text.RegularExpressions.4.0.10-beta-22703\lib\contract\System。 Text.RegularExpressions.dll ^
/r:packages\System.Threading.Overlapped.4.0.0-beta-22703\lib\contract\System.Threading.Overlapped.dll ^
/ R:packages\System.Threading.ThreadPool.4.0.10-β-22703\lib\contract\System.Threading.ThreadPool.dll ^
/r:packages\FSharp.Core.3.1。 2.1\lib\portable-net45 + netcore45 + MonoAndroid1 + MonoTouch1\FSharp.Core.dll ^
/out:runtime\HelloWorld.exe HelloWorld.fs

正如你可以看到我反对建的 FSharp.Core的Profile7
当我运行应用程序的声明让测试= sprintf的你好,世界失败,出现以下异常:



<预类=郎无prettyprint-覆盖> 未处理的异常:System.IO.FileNotFoundException:未能加载文件或程序集系统,版本= 4.0.0.0,文化=中性公钥= 7cec85d7bea7798e或它的一个依赖。该系统找不到指定的文件。
在Microsoft.FSharp.Core.PrintfImpl.PrintfBuilderStack..ctor()
在Microsoft.FSharp.Core.PrintfImpl.PrintfBuilder`3..ctor()
在Microsoft.FSharp.Core .PrintfImpl.Cache`4.generate(字符串FMT)
在Microsoft.FSharp.Core.PrintfImpl.f@4277-43 [T,TSTATE,TResidue,TResult](字符串键,单位unitVar0)
在Microsoft.FSharp.Core.PrintfImpl.Cache`4.get(字符串键)
在Microsoft.FSharp.Core.PrintfImpl.Cache`4.Get(PrintfFormat`4键)
在Microsoft.FSharp .Core.PrintfModule.PrintFormatToStringThen [TResult,T](FSharpFunc`2 continutation,PrintfFormat`4格式)
在HelloWorld.main(字串[] args)

这里我也讨论过这个,但我找不到ŧ找出我做错了。
我有没有包括FSharp.Core的版本不对? Profile7
应该工作


解决方案

在这个时候写的(2015年4月),F#还没有被移植到完全支持CoreCLR / CoreFX。



CoreCLR CoreFX 目前正在进行大量的变化和发展的同时,改善收益。流失会降低和稳定在未来几个月内迅速提高,但建立在这个时候任何的CoreCLR / FX实质性的将是类似于在流沙上建立摩天大楼。



单v.next,这是目前用于构建和[LI | U]运行F#N [U | I] X,也经历了很大的改变。因为它取代了单平台和框架与CoreCLR和CoreFX组件和代码的大块



您可能要跟踪的视觉F#问题#387 的进步。



您可能还需要跟踪的Visual F#问题#336 其中讨论了CoreCLR进行X开发平台支持工作F#。



UPDATE1:



现在的F#4.0发运,团队正在对一堆新作:的https://github.com/Microsoft/visualfsharp/issues/563



键增加了F#CoreCLR支持: https://github.com/Microsoft/visualfsharp/issues/499


I compiled CoreCLR and CoreFX as described here. Basically that works and I can compile and run C# code targeting CoreCLR.
The next step was to try compiling and running F# code. So I added FSharp.Core 3.1.2.1 to the project and compiled a sample application using the following command:

fsc ^
--noframework ^
--targetprofile:netcore ^
/r:packages\System.Runtime.4.0.20-beta-22703\lib\contract\System.Runtime.dll ^
/r:packages\System.Reflection.4.0.10-beta-22703\lib\contract\System.Reflection.dll ^
/r:packages\System.Collections.4.0.10-beta-22703\lib\contract\System.Collections.dll ^
/r:packages\System.Diagnostics.Debug.4.0.10-beta-22703\lib\contract\System.Diagnostics.Debug.dll ^
/r:packages\System.IO.FileSystem.4.0.0-beta-22703\lib\contract\System.IO.FileSystem.dll ^
/r:packages\System.Linq.Expressions.4.0.10-beta-22703\lib\contract\System.Linq.Expressions.dll ^
/r:packages\System.Console.4.0.0-beta-22703\lib\contract\System.Console.dll ^
/r:packages\System.Runtime.Extensions.4.0.10-beta-22703\lib\contract\System.Runtime.Extensions.dll ^
/r:packages\System.Runtime.InteropServices.4.0.20-beta-22703\lib\contract\System.Runtime.InteropServices.dll ^
/r:packages\System.Text.Encoding.4.0.10-beta-22703\lib\contract\System.Text.Encoding.dll ^
/r:packages\System.Text.RegularExpressions.4.0.10-beta-22703\lib\contract\System.Text.RegularExpressions.dll ^
/r:packages\System.Threading.Overlapped.4.0.0-beta-22703\lib\contract\System.Threading.Overlapped.dll ^
/r:packages\System.Threading.ThreadPool.4.0.10-beta-22703\lib\contract\System.Threading.ThreadPool.dll ^
/r:packages\FSharp.Core.3.1.2.1\lib\portable-net45+netcore45+MonoAndroid1+MonoTouch1\FSharp.Core.dll ^
/out:runtime\HelloWorld.exe HelloWorld.fs

As you can see I built against Profile7 of FSharp.Core. When I run the application the statement let test = sprintf "Hello, world" fails with the following exception:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.
   at Microsoft.FSharp.Core.PrintfImpl.PrintfBuilderStack..ctor()
   at Microsoft.FSharp.Core.PrintfImpl.PrintfBuilder`3..ctor()
   at Microsoft.FSharp.Core.PrintfImpl.Cache`4.generate(String fmt)
   at Microsoft.FSharp.Core.PrintfImpl.f@4277-43[T,TState,TResidue,TResult](String key, Unit unitVar0)
   at Microsoft.FSharp.Core.PrintfImpl.Cache`4.get(String key)
   at Microsoft.FSharp.Core.PrintfImpl.Cache`4.Get(PrintfFormat`4 key)
   at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThen[TResult,T](FSharpFunc`2 continutation, PrintfFormat`4 format)
   at HelloWorld.main(String[] args)

I also discussed this here but I couldn't figure out what I am doing wrong. Did I include a wrong version of FSharp.Core? Profile7 should work.

解决方案

At this time of writing (April 2015), F# has not yet been ported to fully support CoreCLR / CoreFX.

CoreCLR and CoreFX are currently undergoing a lot of changes and improvements while development proceeds. The churn will decrease and stability improve rapidly in the coming months, but building anything substantial on CoreCLR/FX at this time will be akin to building a skyscraper on quicksand.

Mono v.next, which is currently used to build and run F# on [LI|U]N[U|I]X, is also undergoing a lot of change as it replaces large chunks of the Mono platform and Framework with assemblies and code from CoreCLR and CoreFX.

You might want to track Visual F# issue #387 for progress.

You may also want to track Visual F# issue #336 which discusses supporting F# on CoreCLR for x-plat work.

Update1:

Now that F# 4.0 is shipped, the team are working on a bunch of new work: https://github.com/Microsoft/visualfsharp/issues/563

Key among those work items is adding CoreCLR support to F#: https://github.com/Microsoft/visualfsharp/issues/499.

这篇关于运行F#中CoreCLR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆