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

问题描述

我编译和描述到项目并使用以下命令编译一个示例应用程序:

  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

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



未处理的异常: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)

这里我也讨论过这个。


解决方案

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



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



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



您可能要跟踪的的进步。



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



UPDATE1:



现在的F#4.0发运,团队正在对一堆新作:的



键增加了F#CoreCLR支持:


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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 20:28