Running F # in CoreCLR

I compiled CoreCLR and CoreFX as described here . This basically works, and I can compile and run the Coreclr oriented C # code.
The next step was to try compiling and running the F # code. So I added FSharp.Core 3.1.2.1 to the project and compiled an example 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 in FSharp.Core. When I run the application, the let test = sprintf "Hello, world" 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 one here , but I could not understand what I was doing wrong. Am I including the wrong version of FSharp.Core? Profile7 should work .

+8
c # f # coreclr
source share
1 answer

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

CoreCLR and CoreFX are undergoing major changes and improvements, while development continues, Scrap will decrease and stability will improve quickly in the coming months, but at the same time creating something significant on CoreCLR / FX at that 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 major changes as it replaces large chunks of the Mono platform and assembly framework and code from CoreCLR and CoreFX.

You may need to track down a problem with Visual F # No. 387 .

You can also keep track of Visual F # issue 336 , which discusses F # support on CoreCLR for x-plat to work.

Update1:

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

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

+15
source share

All Articles