使用 Mono 运行 F# 代码 [英] Running F# code with Mono

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

问题描述

我安装了 F# 2.0.0,并使用了 mono 2.8.

let rec fib n =匹配 n 与|1 |2 ->1|n ->fib(n-1) + fib(n-2)让 n = 40让 x = fib(n)printfn "%d" x

我用 fsc.exe 编译了这段代码以获得 fib.exe.使用 mono fib.exe 运行它会给我这个错误.

<前>单一事实.exe无法加载文件或程序集 'FSharp.Core,版本 = 2.0.0.0,文化 = 中性,PublicKeyToken=b03f5f7f11d50a3a' 或其依赖项之一.未处理的异常:System.TypeLoadException:无法加载类型'.$Factorial' 来自程序集 'factorial, Version=0.0.0.0,文化=中性,PublicKeyToken=null'.

可能有什么问题?

添加

<前>须藤 gacutil -i FSharp.Core.dll

解决了这个问题.

解决方案

F# 程序集(如 FSharp.Core.dll)可能只安装到 .Net GAC.您需要将它们安装到 Mono 的 GAC(Mono 的 gacutil.exe),或者将程序集复制到与可执行文件相同的目录中.

I have F# 2.0.0 installed, and use mono 2.8.

let rec fib n =
    match n with
    | 1 | 2 -> 1
    | n -> fib(n-1) + fib(n-2)

let n = 40
let x = fib(n)
printfn "%d" x

I compiled this code with fsc.exe to get fib.exe. Running this with mono fib.exe gives me this error.

mono fact.exe 
Could not load file or assembly 'FSharp.Core, Version=2.0.0.0, Culture=neutral, 
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

Unhandled Exception: System.TypeLoadException: Could not load type 
'.$Factorial' from assembly 'factorial, Version=0.0.0.0,
 Culture=neutral, PublicKeyToken=null'.

What might be wrong?

ADDED

sudo gacutil -i FSharp.Core.dll 

solved this problem.

解决方案

The F# assemblies (like FSharp.Core.dll) are probably only installed to the .Net GAC. You need to install them to Mono's GAC (Mono's gacutil.exe), or copy the assemblies into the same directory as your executable.

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

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