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

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

问题描述

我已安装F#2.0.0,并使用单声道2.8.

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

我使用fsc.exe编译了此代码,以获得fib.exe.与mono fib.exe一起运行会给我这个错误.

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'.

怎么了?


sudo gacutil -i FSharp.Core.dll 

解决了这个问题.

推荐答案

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

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天全站免登陆