在MONO下,F#代码的简单片段不起作用

时间:2013-04-26 22:48:43

标签: f# mono f#-3.0

以下是一些不会因复杂性而获奖的代码:

[<EntryPoint>]
let main argv =
   let i = 1I
   printfn "One is %A\n" i
   0 // return an integer exit code

编译如下:&#34; c:/ Program Files(x86)/ Microsoft SDKs / F#/ 3.0 / Framework / v4.0 / Fsc.exe&#34; --out:numericstest.exe --debug:full --target:exe --standalone Program.fs

在Windows下,它会产生预期的结果。但是根据在Ubuntu下编译的Mono 3.0.7,它反而说:

mono numericstest.exe

Unhandled Exception: System.InvalidProgramException: Invalid IL code in System.Numerics.BigInteger:get_One (): method body is empty.

at Program.main (System.String[] argv) [0x00000] in <filename unknown>:0[ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidProgramException: Invalid IL code in System.Numerics.BigInteger:get_One (): method body is empty.

at Program.main (System.String[] argv) [0x00000] in <filename unknown>:0

我做错了什么?非常感谢。

1 个答案:

答案 0 :(得分:2)

您的代码没有任何问题 - 该异常是由您的代码造成的。您的计算机上的System.Numerics.dll程序集看起来有问题;要么它没有正确安装,要么编译不正确(例如,通过Mono C#编译器),要么它正在进行某种类型的转发,这种类型转发不能正常工作,等等。

如果在不使用BigInteger(通过I后缀)的情况下运行代码会发生什么?


我在VirtualBox下运行的Ubuntu(12.04,32位)VM中尝试了您的代码。代码编译并按预期运行。如果您愿意,请输出以下内容:

<强>编译/运行

jack@jack-linux:~/Desktop$ fsharpc --out:JoeHuha.exe --debug:full --target:exe --standalone JoeHuha.fs
F# Compiler for F# 3.0 (Open Source Edition)
Freely distributed under the Apache 2.0 Open Source License
jack@jack-linux:~/Desktop$ mono JoeHuha.exe
One is 1

单声道版本信息

jack@jack-linux:~/Desktop$ mono -V
Mono JIT compiler version 3.0.5 (master/1643364 Fri Feb 22 19:31:07 EST 2013)
Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
    TLS:           __thread
    SIGSEGV:       altstack
    Notifications: epoll
    Architecture:  x86
    Disabled:      none
    Misc:          softdebug 
    LLVM:          supported, not enabled.
    GC:            Included Boehm (with typed GC and Parallel Mark)